I’ve set up an HTML form that has select boxes added to it dynamically, based on the number of records selected from a database.
A while loop in php adds the following to the form for each database record found:
[CODE]<tr>
<td>No. of Catalogues:
<select name=”catarray[]” onChange=”doTotal(this.form)”;>
<option value=”0″>0</option>
<option value=”4″>1</option>
<option value=”8″>2</option>
<option value=”12″>3</option>
<option value=”16″>4</option>
<option value=”20″>5</option>
</select>
</td>
</tr>
So if there are 3 records, the form displays:
No. of Catalogs: [I]select box
No. of Catalogs: [I]select box
No. of Catalogs: [I]select box
I want to use the javascript doTotal() function to total the values in all of the selected options as selections are made. I’m able to determine the number of select boxes that have been added to the form, but I can’t get the syntax right to access the select box values. I keep getting a ‘NaN’ or ‘undefined’ error.
Is this possible? – am I using the correct syntax for adding the ‘catarray’ select boxes? can anyone help with the javascript to access the value in each select box?