Hi, I am looking for some help with HTML forms, namely forms which mainly comprise of drop-down boxes. I know how to create drop-down boxes in forms, though what I want is that each variable in the drop-down box should go to a different URL. For example, if someone selects "variable 1" and then clicks submit, it should go to a different URL than when they select "variable 2" and click submit. I have all the URL's, though I'm just not sure of how to make each variable go to a different URL. Can someone help me out with this? If anyone knows of a site which has something similar like this can you please direct me to it so that I can look at he source? Thanks.
Hi, you need some javascript to do that: <select name="dropdown1"> <option value="http://www.google.com">http://www.google.com</option> <option value="http://www.yahoo.com">http://www.yahoo.com</option> </select> <input id="Submit1" type="submit" value="Go Url" onclick="gotoUrl()" /> <script type="text/javascript"> function gotoUrl() { var theUrl = document.getElementById('dropdown1')[document.getElementById('dropdown1').selectedIndex].innerHTML; window.location.href=theUrl; } </script> Code (markup): I hope this is what you are looking for.
I tested it in IE and it worked fine. I just tested it in Firefox and it did not work. I cant get it to work so fast in FF but check out this code, if you can do it onchange of the drop down. Here is the code that should work in FF and IE <form name="theform"> <select name="dropdownlist1" size="3" OnChange="location.href=theform.dropdownlist1.options[selectedIndex].value"> <option value="http://www.google.com/">google.com <option value="http://www.yahoo.com/">yahoo.com <option value="http://www.digitalpoint.com/">digitalpoint.com </select> </form> Code (markup):