?
Solved

Help with Cobmo Box Posting URL

Posted on 2004-04-26
3
Medium Priority
?
166 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 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

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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

762 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