Skip to content

Instantly share code, notes, and snippets.

@sruli
Last active December 11, 2015 03:58
Show Gist options
  • Save sruli/4541699 to your computer and use it in GitHub Desktop.
Save sruli/4541699 to your computer and use it in GitHub Desktop.
addLoadEvent(function() {
var dropdowns = form.getElementsByTagName("select");
setInterval(function() {
for(var i = 0; i < dropdowns.length; ++i) {
if(dropdowns[i].value != "") {
if(document.getElementsByClassName(dropdowns[i].id).length == 0) {
var input = document.createElement("input");
input.type = "hidden";
input.className = dropdowns[i].id;
input.name = "lists[]";
input.value = "108";
form.appendChild(input);
}
} else {
var input = document.getElementsByClassName(dropdowns[i].id);
if(input.length != 0) {
input[0].parentNode.removeChild(input[0]);
}
}
}
}, 3000);
});
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment