?
Solved

Help with Cobmo Box Posting URL

Posted on 2004-04-26
3
Medium Priority
?
170 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
1 Comment
 
LVL 3

Accepted Solution

by:
Yasir_Malik earned 500 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.
Suggested Courses
Course of the Month15 days, 11 hours left to enroll

850 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