dropdown.js
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:4k
- function update(e, dd, subMenuNum)
- {
- dd[0][2] = "SO" + subMenuNum;
- dd[0][1] = "OPT" + subMenuNum;
- for (j=1; j < dd.length; j++)
- {
- dd[j][0] = true; // Options every first row in the array true
-
- }
- for (j=1; j < dd[0].length; j++) //loop through first row (getting headings) of array
- {
- for (i=1; i < dd.length; i++) //for each heading
- {
-
-
-
- current = dd[i][j].split("|"); //split the current heading
- value = current[0]; //place values into variable
- choice = current[0];
- if (current.length == 2) choice = current[1]; // split if need arises
- if (value != document[dd[0][0]][dd[0][j]][document[dd[0][0]][dd[0][j]].selectedIndex].value) dd[i][0] = false;
- //document[dd[0][0]][dd[0][j]][document[dd[0][0]][dd[0][j]].selectedIndex].value = what is selected?
- if(dd[i][0]){
- var NLayer = "Layer" + subMenuNum;
- if(dd[i][2]){
-
- MM_showHideLayers(NLayer,'','show')
- }else{
- MM_showHideLayers(NLayer,'','hide')
- }
- }
-
- }
-
- if (e == document[dd[0][0]][dd[0][j]])
- {
-
- dropdown(j+1,dd,subMenuNum);
- for (k=j+2; k < dd[0].length; k++)
- {
- document[dd[0][0]][dd[0][k]].length = 0;
-
- }
- break;
- }
- }
- }
- function dropdown(item,dd, id)
- {
- var pre1 = "";
- var j = 1;
- var defaultselect = 0;
- dd[0][2] = "SO" + id;
- dd[0][1] = "OPT" + id;
-
- if(dd[0][0]){
- if(dd[0][item]){
- document[dd[0][0]][dd[0][item]].options.length = 0;
- document[dd[0][0]][dd[0][item]].options[0] = new Option('Select...', '');
- }
- }
- for (i=1; i < dd.length; i++)
- {
- if (dd[i][0] || item == 1)
- {
-
- if(dd[i][item]){
-
- current = dd[i][item].split("|");
- }
-
- value = current[0];
- choice = current[0];
- //Changes made to set default selection **********************************
- defaultselected=current[2];
- // if (current.length == 2) choice = current[1];
- if (current.length >= 2) choice = current[1];
- // ***************************************
- if (value != pre1)
- {
- var op = new Option(choice, value);
- document[dd[0][0]][dd[0][item]].options[j] = op;
- //***********************************
- if (defaultselected)
- {
- document[dd[0][0]][dd[0][item]].selectedIndex=j;
- }
- // *******************************************************
- j++;
- pre1 = value;
- }
- }
- }
- }
- function MM_reloadPage(init) { //reloads the window if Nav4 resized
- if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
- document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
- else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
- }
- MM_reloadPage(true);
- function MM_findObj(n, d) { //v4.0
- 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 && document.getElementById) x=document.getElementById(n); return x;
- }
- function MM_showHideLayers() { //v3.0
- var i,p,v,obj,args=MM_showHideLayers.arguments;
- for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
- if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
- obj.visibility=v; }
- }
- function ValidateSelection()
- {
- var EmailNo;
- var NLayer = "Layer";
- var ValidateSelect;
- // sort out all Comboboxes
- var arrayOfSelects = document.all.tags("Select");
- // Iterate through all elements on document
- for(i=0;i<arrayOfSelects.length;i++)
- {
- var ObjectName = new String(arrayOfSelects[i].name);
- NLayer="Layer";
- // If Element name starts with "OPT" means it is first combo and validate it
- if (ObjectName.indexOf("OPT") == 0)
- {
- // get Number assigned to Combo
- EmailNo=ObjectName.substring(3);
- //If Nothing is selected in Combo
- //if (document["form"][ObjectName].selectedIndex==0)
- //{
- // alert("Please select any option for Email [ " + EmailNo + " ]");
- // return false;
- //}
- //Build respective layer name for combo
- NLayer = NLayer + EmailNo;
- if ((obj=MM_findObj(NLayer))!=null)
- {
- obj=obj.style;
- // If secend combo is visible then validate it
- if (obj.visibility=="visible")
- {
- ValidateSelect = "SO"+EmailNo;
- if (document["form"][ValidateSelect].selectedIndex==0)
- {
- alert("Please select any option for Email [ " + EmailNo + " ]");
- return false;
- }
- }
- }
- }
- }
- return true;
- }