crazybmanp Posted August 20, 2008 Author Posted August 20, 2008 So what would the code that stores the value in the variable url look like?
Ashoat Posted August 20, 2008 Posted August 20, 2008 I recommend you Google to understand this, as it's pretty easy. I've explained how it works, but I don't want to write your code for you.
crazybmanp Posted August 23, 2008 Author Posted August 23, 2008 I searched google, and tried it several different ways myself, and it all failed. Could someone please help me understand how to use the ID attribute to get the value from the drop-down box. (you don't have to write the code, just help me understand)
Ashoat Posted August 23, 2008 Posted August 23, 2008 As I mentioned earlier: document.getElementById("id_of_your_dropdown").value.
crazybmanp Posted August 23, 2008 Author Posted August 23, 2008 right after i made this post i figured out how to do it, i belive the code is still acting up, but i think its the line that makes the browser navigate, i can fix that though.
Byron Posted August 23, 2008 Posted August 23, 2008 Does it just HAVE to be written that way? Will this not work for you? <form name="" method="post" action="" enctype="application/x-www-form-urlencoded"> <select name="jump" size="1" onChange="location.href=(this.options[this.selectedIndex].value)"> <option> - Links - </option> <option value="http://">Link</option> <option value="http://">Link</option> <option value="http://">Link</option> <option value="http://">Link</option> <option value="http://">Link</option> </select> </form>
Wizard Posted August 23, 2008 Posted August 23, 2008 Does it just HAVE to be written that way? Will this not work for you? <form name="" method="post" action="" enctype="application/x-www-form-urlencoded"> <select name="jump" size="1" onChange="location.href=(this.options[this.selectedIndex].value)"> <option> - Links - </option> <option value="http://">Link</option> <option value="http://">Link</option> <option value="http://">Link</option> <option value="http://">Link</option> <option value="http://">Link</option> </select> </form> Byron wins.
crazybmanp Posted August 23, 2008 Author Posted August 23, 2008 well, i wanted to have the script in the header so i could easily impliment multiple boxes ps: i have the working code written. <html> <head><script LANGUAGE="JavaScript"> function formHandler(x){ var y=document.getElementById(x); var l=y.selectedIndex; var m=y[l].value; window.location= m; } /*instructions: insert the code that is in the header in the header part of your page, and the body code into your page where you want the box to appear you can add more options by adding more lines just like the existing ones. in order to support multiple drop-down boxes on one page, you can copy the select object and rename the ID tag to something else ex:site2 made by: crazybmanp*/ </SCRIPT> </head> <body> <select ID="site" size=1 onchange="formHandler(this.id)"> <option value="">Go to... <option value="http://gamer-hotspot.heliohost.org/blog">Blog <option value="http://gamer-hotspot.heliohost.org/forum/">Forum </select> </body> </html>
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now