Solved

Help with Cobmo Box Posting URL

Posted on 2004-04-26
3
158 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
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now