How can I get the values into the 3 combo boxes I am using dynamically from a database?
Created May 7, 2012
idris yuce
//Text will be shown in the second combo combo2Text=new Array(2); //Values of second combobox elements combo2Values=new Array(2); combo2Text[0]=new Array('one','two','three'); combo2Values[0]=new Array('1','2','3'); combo2Text[1]=new Array('ten','twenty','thirty'); combo2Values[1]=new Array('10','20','30'); //combo1: first combobox's name //combo2: second combobox's name //formname: form's name function setCombo2(){ mIndex=document.formname.combo1.selectedIndex; document.formname.combo1.length=combo2Text[mIndex].length; for(i=0; i<combo2Text[mIndex].length; i++){ document.formname.combo2.options[i].text=combo2Text[mIndex][i]; document.formname.combo2.options[i].value=combo2Values[mIndex][i]; } document.formname.combo1.options[0].selected=true; }call this function on the onChange event of the combo1 in order to set the elements in the second combo. I assumed you will have two elements in the first combobox. If you have more element you should write the related array both for text and values of this element.