Skip to content

Instantly share code, notes, and snippets.

Created February 9, 2012 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1781937 to your computer and use it in GitHub Desktop.
Save anonymous/1781937 to your computer and use it in GitHub Desktop.
arrDynaList[2646] = "12"
arrDynaList[2647] = "WRECK"
arrDynaList[2648] = "WRECK"
arrDynaList[2649] = "11"
arrDynaList[2650] = "YARD"
arrDynaList[2651] = "YARD"
//-->
</script>
<!-- End of object/array definitions, beginning of generic functions -->
<script language="JavaScript">
<!--
function setDynaList(arrDL){
var oList1 = document.forms[arrDL[2]].elements[arrDL[1]];
var oList2 = document.forms[arrDL[4]].elements[arrDL[3]];
var arrList = arrDL[5];
clearDynaList(oList2);
if (oList1.selectedIndex == -1){
oList1.selectedIndex = 0;
}
populateDynaList(oList2, oList1[oList1.selectedIndex].value, arrList);
return true;
}
function clearDynaList(oList){
for (var i = oList.options.length; i >= 0; i--){
oList.options[i] = null;
}
oList.selectedIndex = -1;
}
/*This is a modified function from the original MM script. Mick White
added the first line of oList so there would be an initial selection.
Needed this if there is only 1 child menu item, otherwise, the single
child menu item would be already hihghlighted and you can not select
it. Also good for validation purposes so you can set the .js
validation to not allow the first selection.
*/
function populateDynaList(oList, nIndex, aArray){
oList[oList.length]= new Option(" ");
for (var i = 0; i < aArray.length; i= i + 3){
if (aArray[i] == nIndex){
oList.options[oList.options.length] = new Option(aArray[i + 1], aArray[i + 2]);
}
//oList.size=oList.length //You need to comment out this line of the function if you use this mod
}
//A quick mod here, I changed the ==0 to ==1 so that the length
//takes into account the Please select option from above.
if (oList.options.length == 1){
oList.options[oList.options.length] = new Option(":: No SubCategories Available ::");
}
oList.selectedIndex = 0;
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_jumpMenuGo(selName,targ,restore){ //v3.0
var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
//-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment