-
-
Save marcheiligers/4545351 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addLoadEvent(function() { | |
var dropdowns = form.getElementsByTagName("select"); | |
for(var i = 0; i < dropdowns.length; ++i) { | |
dropdowns[i].onchange = (function() { | |
var dropdown = dropdowns[i]; | |
return function() { | |
if(dropdown.value != "") { | |
if(document.getElementsByClassName(dropdown.id).length == 0) { | |
var input = document.createElement("input"); | |
input.type = "hidden"; | |
input.className = dropdown.id; | |
input.name = "lists[]"; | |
input.value = "108"; | |
form.appendChild(input); | |
} | |
} else { | |
var input = document.getElementsByClassName(dropdown.id); | |
// TODO: There be another problem here --------^ | |
if(input.length != 0) { | |
input[0].parentNode.removeChild(input[0]); | |
} | |
} | |
} | |
})(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment