solidrichard Posted May 15, 2011 Share Posted May 15, 2011 hi , I have drop down box $sql= "select * from table where nabor='1'" ; $vysledek=mysql_query($sql); $moznosti=""; while ($row=mysql_fetch_array($vysledek)) { $id=$row["id"]; $projekt=$row["projekt"]; $moznosti.="<OPTION VALUE=\"$id\">".$projekt; <SELECT NAME=projekt> <OPTION VALUE=0>Vyberte <?=$moznosti?> </SELECT> And I want if someone select project with for example id=5 link to another website... Thanks for any answers Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted May 15, 2011 Share Posted May 15, 2011 You want it to redirect them to another site? Well then you'd need a bit of JavaScript, not PHP. <select name="projekt" onchange="javascript: window.location=this.options[this.options.selectedIndex].value"> Then you can set the value to the location of each site, example: $moznosti .= '<option value="http://examplesite.com/something.php?id=' . $id . '">' . $projekt . '</option>'; Going on memory here, not tested. Good luck. Quote Link to comment Share on other sites More sharing options...
solidrichard Posted May 15, 2011 Author Share Posted May 15, 2011 Working thanks Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted May 15, 2011 Share Posted May 15, 2011 Be aware though that this does rely on the user having JavaScript enabled. Majority do these days, not sure how common it is for it to be disabled. But just be aware of that fact. Glad it worked. Hit the solved, bottom left of page, if you don't mind. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.