Good day to all)
Took example from the site , Demo 6
Everything works fine, though I can not understand how to put a handler on <select>
, which would take value from there. That is, so that when the selector changes, the "content" changes.
Here is the code for the selector itself:
<select id="cd-dropdown" class="cd-select"> <option value="-1" selected>Choose an animal</option> <option value="1" class="icon-monkey">Monkey</option> <option value="2" class="icon-bear">Bear</option> <option value="3" class="icon-squirrel">Squirrel</option> <option value="4" class="icon-elephant">Elephant</option> </select>
but the page itself is already displayed
<div class="cd-dropdown"> <span>Choose an animal</span> <input type="hidden" name="cd-dropdown"> <ul> <li data-value="1"><span class="icon-monkey">Monkey</span></li> <li data-value="2"><span class="icon-bear">Bear</span></li> <li data-value="3"><span class="icon-squirrel">Squirrel</span></li> <li data-value="4"><span class="icon-elephant">Elephant</span></li> </ul> </div>
I understand that this "transformation" occurs in
jquery.dropdown.js
created 2 forms, forma1 with id = "f1", and similarly form2 with id = "f2", hide made one form on the select
onChange = "func (this.value)" but the function itself
function func(par){ if(par==1){ document.getElementById('f'+par).style.display=''; document.getElementById('f'+2).style.display='none'; }else{ document.getElementById('f'+par).style.display=''; document.getElementById('f'+1).style.display='none'; } }
if it's a normal selector, then the function works.
when choosing different selects, the value changes
<input type="hidden" name="cd-dropdown">
Tell me how to refer to this input, and when the value changes so that it runs func (). Thank you very much in advance))