<!doctype html>
<html>
<head>
<title>Multiple or Single Select of Dropdown Proof of Concept - RJM Programming - October, 2016</title>
<script type='text/javascript'>
var sit=-1;
var ourtwo=2;
var ourselo=null;
var sitlist='';
var sitdelim='';
var lastsit='';
var sitideastarted=false;
var callwhat=[];
function sitidea() {
if (sit >= 0) {
if (sit == 0) sitdelim='';
sit++;
}
if (sit > 4) {
if (sitlist.indexOf(',') != -1) {
document.getElementById('myp').innerHTML+=callwhat.length + ' ' + sitlist + String.fromCharCode(10);
dowhat();
} else {
dowhat();
}
sitlist='';
setdelim='';
sit=-1;
} else if (sit < 0) {
sitlist='';
setdelim='';
}
setTimeout(sitidea, 1000);
}
function ourchanged(via, p1, p2, p3, p4, p5, p6, p7, p8, p9) {
lastsit=p1;
if (sit >= 0) {
if (lastsit != '') {
if (sitlist != '') sitdelim=',';
if (sitlist.indexOf(lastsit) == -1) sitlist+=sitdelim + lastsit;
sitdelim=',';
lastsit='';
}
}
if (ourtwo == 2) {
callwhat.push(via(p1,p2));
} else if (ourtwo == 1) {
callwhat.push(via(p1));
} else if (ourtwo == 3) {
callwhat.push(via(p1,p2,p3));
} else if (ourtwo == 4) {
callwhat.push(via(p1, p2, p3, p4));
} else if (ourtwo == 5) {
callwhat.push(via(p1, p2, p3, p4, p5));
} else if (ourtwo == 6) {
callwhat.push(via(p1, p2, p3, p4, p5, p6));
} else if (ourtwo == 7) {
callwhat.push(via(p1, p2, p3, p4, p5, p6, p7));
} else if (ourtwo == 8) {
callwhat.push(via(p1, p2, p3, p4, p5, p6, p7, p8));
} else if (ourtwo == 9) {
callwhat.push(via(p1, p2, p3, p4, p5, p6, p7, p8, p9));
}
}
function checkclass(proposedclass) {
var pclass=proposedclass, sels, isels, ijl, divo=null, divid='', fncnt=0, tbit='';
if (pclass == "") pclass="select_ms";
setTimeout(sitidea, 1000);
//var huhs=document.getElementsByTagName('div');
//for (ijl=0; ijl<huhs.length; ijl++) {
// if (huhs[ijl].innerHTML == '') {
// if (huhs[ijl].id != '') {
// divo=huhs[ijl];
// divid=huhs[ijl].id;
// }
// }
//}
//if (divid != '' || 1 == 1) {
sels=docgetclass(pclass, "select");
for (isels=0; isels<sels.length; isels++) {
if (typeof sels[isels].onchange === "undefined") {
if (1 == 3) alert("Sels[isels].onchange?");
} else if (sels[isels].onchange) {
fncnt++;
//document.getElementById(divid).innerHTML='<scr' + 'ipt type="text/javascript"> function ourchanged(x,y) { alert(96); } </scr' + 'ipt> ';
//alert(sels[isels].onchange);
var argbit='', argdelim='', rest='';
var precallis=('' + sels[isels].onchange).replace('function onchange(event)','').replace('{','').replace('}','').replace('(',',').replace(');','');
var postcallis='arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9'.split(',');
var callis=precallis.split(',');
ourtwo=0;
for (var ic=1; ic<callis.length; ic++) {
ourtwo++;
argbit+=argdelim + postcallis[ic];
if (ic > 2) rest+=argdelim + "String.fromCharCode(32)";
argdelim=',';
tbit+=argdelim + callis[ic];
}
//alert("setTimeout(" + ('' + sels[isels].onchange).replace(" onchange(event)", "()") + ", 4000);");
//if (fncnt == 1) sels[isels].addEventListener("change", fn3(changed,event), false); //eval("setTimeout(" + ('' + sels[isels].onchange).replace(' onchange(event)', '()') + ", 4000);");
//alert(' if (sit < 4) { sit=0; setTimeout(function(' + argbit + ') { ourchanged(' + callis[0] + ',' + argbit + '); }, 4000, this.value,this.innerHTML' + rest + '); } else { sit=-1; } ');
ourselo=sels[isels];
//alert(tbit);
eval("sels[" + isels + "].onchange=null");
if (window.addEventListener) {
eval("sels[" + isels + "].addEventListener('change', function() { if (sit < 4) { sit=0; setTimeout(function(" + argbit + ") { ourchanged(" + callis[0] + "," + argbit + "); }, 4000" + tbit + rest + "); } else { sit=-1; } })");
} else {
eval("sels[" + isels + "].attachEvent('change', function() { if (sit < 4) { sit=0; setTimeout(function(" + argbit + ") { ourchanged(" + callis[0] + "," + argbit + "); }, 4000" + tbit + rest + "); } else { sit=-1; } })");
}
// //sels[isels].innerHTML=sels[isels].innerHTML.replace(/<option /g, '<option ontouchdown=" if (sit < 4) { sit=0; setTimeout(function(' + argbit + ') { ourchanged(' + callis[0] + ',' + argbit + '); }, 4000, this.value,this.innerHTML' + rest + '); } else { sit=-1; } " onmousedown=" if (sit < 4) { sit=0; setTimeout(function(' + argbit + ') { ourchanged(' + callis[0] + ',' + argbit + '); }, 4000, this.value,this.innerHTML' + rest + '); } else { sit=-1; alert(831); } " ');
//alert(sels[isels].innerHTML);
}
}
}
function docgetclass(inc, intag) {
if (document.getElementsByClassName) {
return document.getElementsByClassName(inc);
} else {
var ijl;
var anarris=[];
var huhs=document.getElementsByTagName(intag);
for (ijl=0; ijl<huhs.length; ijl++) {
if (huh[ijl].className.indexOf(inc) != -1 || 1 == 1) {
anarris.push(huhs[ijl]);
}
}
return anarris;
}
}
function clicked(inval) {
//alert(inval);
}
function changed(inval,intxt) {
//alert(inval + ' ... ' + intxt);
document.getElementById('myp').innerHTML+=inval + ' ... ' + intxt + String.fromCharCode(10);
}
function dowhat() {
callwhat[eval(-1 + callwhat.length)];
callwhat.pop();
if (callwhat.length >= 1) dowhat();
}
</script>
</head>
<body onload=' checkclass("select_ms");'>
<select class='select_ms' size=8 onchange=' changed(this.value,this.options[this.selectedIndex].text); '>
<option value='Queensland'>Queensland</option>
<option value='New South Wales'>New South Wales</option>
<option value='Australian Capital Territory'>Australian Capital Territory</option>
<option value='Victoria'>Victoria</option>
<option value='Tasmania'>Tasmania</option>
<option value='South Australia'>South Australia</option>
<option value='Western Australia'>Western Australia</option>
<option value='Northern Territory'>Northern Territory</option>
</select>
<select><option value=huh>huh</option></select>
<br><textarea id='myp' style='width:100%;' rows=100></textarea><br>
<div id='forscript'></div>
</body>
</html>