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 Link to comment https://forums.phpfreaks.com/topic/236455-drop-down-box-link/ 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. Link to comment https://forums.phpfreaks.com/topic/236455-drop-down-box-link/#findComment-1215652 Share on other sites More sharing options...
solidrichard Posted May 15, 2011 Author Share Posted May 15, 2011 Working thanks Link to comment https://forums.phpfreaks.com/topic/236455-drop-down-box-link/#findComment-1215655 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. Link to comment https://forums.phpfreaks.com/topic/236455-drop-down-box-link/#findComment-1215660 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.