I loop through the options array of the select element in my function and only add elements to the array if they have been selected. So what is happening?
,,,,,,,,,,,,,,,15. Layout,,,,,,,,,,,,,,,,,,,,,,,,,40. Enviromental,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,70. Concrete and Asphalt Lab.
15
"15. Layout"
40
"40. Enviromental"
70
"70. Concrete and Asphalt Lab."
Expand|Select|Wrap|Line Numbers
- <select
- id ="PHASECODE"
- name="PHASECODE"
- class="InputText"
- disabled="disabled"
- multiple="multiple"
- size="10"
- >
- <option value="10">10. Drilling</option>
- <option value="15">15. Layout</option>
- <option value="30">30. Geotechnical Eng.</option>
- <option value="40">40. Enviromental</option>
- <option value="50">50. Design Services</option>
- <option value="60">60. Construction Material Eng.</option>
- <option value="70">70. Concrete and Asphalt Lab.</option>
- <option value="80">80. Soils Lab.</option>
- <option value="92">92. Maint. Shop Activites</option>
- </select>
- <input
- type="button"
- id="bAddPhaseCodes"
- value="Add more Depts. to this template"
- onclick="addPhase(this);"
- >
- function addPhase(obj)
- {
- cGroupName = document.getElementById("GROUPNAME").value;
- cDept = document.getElementById("JDEPTID").value;
- for (var i = 0; i < document.getElementById("PHASECODE").options.length; i++ )
- {
- if ( document.getElementById("PHASECODE").options[i].selected )
- {
- aPhaseCodes[document.getElementById("PHASECODE").options[i].value] = document.getElementById("PHASECODE").options[i].text;
- }
- }
- //add phase codes to department array
- aDept[cDept] = aPhaseCodes
- //add department array to group name (template) array
- aTemplates[cGroupName] = aDept;
- alert(aPhaseCodes.length);
- }