Solved

Help with Cobmo Box Posting URL

Posted on 2004-04-26
3
161 Views
Last Modified: 2008-03-10
I am kind new to PHP and learning quick.  But I ran into a speed bump.

I have a combobox that fills with the contents from a MySQL DB.  I want to be able to select an option in the combobox click the go button and go to a url based on the selection of the combobox.

Here is what i currently have:


....code
print("<form name=form1 method=post style=display: inline; margin: 0; padding: 0;>");
print("<select name=select>");
while ($row = mysql_fetch_array ($result))
      {  
      print("<option value=cat4.php?GEN=$gender&BR=".urlencode(stripslashes($row[BRAND])).">".stripslashes($row[BRAND])."</option>");
      }
  print("<input type=submit value=go></select></form>");

// Close the access to mysql database
mysql_close ($link);
print ("</p></font></td></tr>\n");
print ("</table>\n");
?>


The answer is probably easy but I'm giving 125pts because I want to get this little thing done.

Thanks
0
Comment
Question by:dspavlik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
Yasir_Malik earned 125 total points
ID: 10920656
You need some JavaScript magic:

print("<form name=form1 method=post style=display: inline; margin: 0; padding: 0;>");
print("<select name=select>");
while ($row = mysql_fetch_array ($result))
     {  
     print("<option value=cat4.php?GEN=$gender&BR=".urlencode(stripslashes($row[BRAND])).">".stripslashes($row[BRAND])."</option>");
     }
  print('<input type="submit" value="go" onsubmit="location.href=form1.select.options[selectedIndex].value"></select></form>');

I would recommend enclosing all your attributes in quotes ("" "") like I've done.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question