To create a JavaScript array based on the selected values from multiple drop down lists, each with the same name due to being generated in a for loop, the following code snippet is currently being used:
<script language="JavaScript">
var array = [];
var e = document.getElementById("phItemStatusID").value; //returns first ddl value
</script>
Later in the ASP code, a drop down list is populated from a database using VBScript:
<%for i = 0 to UBound(photoItemsArray,2)%> //for each item, generate DDL
<select name="phItemStatusID">
itemStatusID = photoItemsArray(6,i) //get current selected value
for j = 0 to UBound(photoStatusesArray,2)%> //for each possible status
<option value="<%=photoStatusesArray(0,j)%>"
<%if photoStatusesArray(0,j) = itemStatusID then%>
selected
<%end if%>>
<%=photoStatusesArray(1,j)%>
</option>
<%next%>
</select>
next%>
While this setup functions when only one drop down list is generated, issues arise when there are multiple lists with the name phItemStatusID
.
The line
var e = document.getElementById("phItemStatusID").value;
currently only retrieves the value from the first drop down list, ignoring the others. The challenge is in obtaining values from all the dropdown lists. How can this be achieved?