Hello all i want to create multiple drop down list on one page. right now am getting stuck at the js. Could you please advs or point me to a link w/some info on it. The links i found so far only have info on one list per page.
created a codepen, it is not displaying the from correctly. which as far as i can tell are fine.
I don’t understand what you are doing with the JS but you are missing the 2 closing select tags in your html
You can’t put anchors in option tags either as that is not valid.
If you can clarify your question and explain what you are trying to do then I’m sure someone will pipe up with the answer
Dang them select tag! I kept looking at the divs…drrrrr.
I am trying to find a general js script to activate multiple drop down list on a page. so in case i want to add four or six more the same js will work for all.
thank you Paul!
What do you mean by activate exactly?
What is you aim here as I don’t see what you are trying to do? Selects works fine by themselves so I feel you must have some other purpose that is eluding me
gm Paul! I am looking for a js script that will take the user to their selection, preferably w/out a submit button. and that can be used regardless of how many drop down lists i add to the page.
thx
D
Do you mean a url destination?
e.g.
<select name="form" onchange="location = this.options[this.selectedIndex].value;">
<option value="">Select item</option>
<option value="http://www.google.com">Google</option>
<option value="http://yahoo.com">Yahoo</option>
</select>
Of course you shouldn’t use an inline handler but that’s just for example.
Also its not very friendly as it requires js to be on before you can navigate. If that’s what you meant then you would be better of using a standard html menu list first and then replacing it with js to the above. Or just creating the whole thing in html/ CSS and a little js for the click action.
hmmm was told that js had to be used to make it work. i think it might be the case here.
i 'll try again by putting the test url in the value.
in hindsight i had not done that.
thank you Paul!
Paul i tried your example ( & have not done a form before, so sorry this is a stupid post)
am i supposed to add a submit button?
i would think not due to the “onchange”,
thx
D
No, the onchange triggers the script to parse the value as a url and sends you to that location.
The code I posted was a working example.
I still have to ask why this may be a good idea?
well i tested it in the codepen. why wouldn’t it work?
good point on the “good idea” might switch to just a list w/the links, but must admit by now i’d love to see this work too.
D
It’s probably because codepen is sandboxed inside an iframe.
Just try it on a normal page and it will work.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.