Hi Friends, I want to know how to load a page as and when a value in the dropdown is selected based on the recently selected value. Suppose: Now say the page loaded it a.html and it has a dropdown when user changes selection in the dropdown to say B, the b.html should be loaded, it changed to C the c.html. Please note i don't want ot put any button or anything , appropriate page is loaded automatically once option is changed. Thanks a lot for ur help.. Regards,
There is the 'onChange' event that gets fired when a select drop down's selected item is changed. The code should look something like this: <script type="text/javascript"> function redirectMe (sel) { var url = sel[sel.selectedIndex].value; window.location = url; } </script> <select name="myselect" onchange="redirectMe(this);"> <option value="a.html">A</option> <option value="b.html">B</option> <option value="c.html">C</option> </select> Code (markup):
I know this thread is old now, but this is really similar to what I am after. My only prob is that i need to change the folder that the html file is in as opposed to the html file itself E.g. Instead of http://www.website.com/a.html http://www.website.com/b.html http://www.website.com/c.html I need http://www.website.com/a/index.html http://www.website.com/b/index.html http://www.website.com/c/index.html Any ideas?
Hi, just change the value of the options to your desired URL's like bellow: this would work with your example links. <script type="text/javascript"> function redirectMe (sel) { var url = sel[sel.selectedIndex].value; window.location = url; } </script> <select name="myselect" onchange="redirectMe(this);"> <option value="http://www.website.com/a/index.html">A</option> <option value="http://www.website.com/b/index.html">B</option> <option value="http://www.website.com/c/index.html">C</option> </select> Code (markup): Hope this helps, cheers
I have a similar issue, how do i get this to put the value in the action. function redirectMe (sel) { var url = sel[sel.selectedIndex].value; window.location = url; } <form name="myselect" onchange="redirectMe(this);"> <p align="center"> <input type="hidden" name="join_event_id" id="join_event_id" value="<?php echo $event ?>"> <br> </p> <p align="center"> <span class="text">Choose Candidate: </span><span class="style6"> <select name="candidate" class="text" id="position"> <?php $sql = "SELECT `id`, `name` FROM `bio` WHERE `event` = '$event'"; $result2 = mysql_query($sql); if(mysql_affected_rows() > 0) { while ($row = mysql_fetch_assoc($result2)) { echo '<option value="' . $row['id'] . '" '; if($id == $row['id']) echo 'selected="selected"'; echo '>' . $row['name'] . '</option>'; } } ?> </select> </span> </p> <div align="center"> <input type="hidden" name="MM_insert" value="form1"> </div> </form> PHP: