EDIT – Thanks all – I knew it would be simple…couldn’t see the wood from the trees!
var abc = new Array('Perth','Auckland');
case '1':
document.getElementById(q15).options.length = 0;
for (i = 0; i < abc.length; i++) {
createOption(document.getElementById(q15), abc[i], abc.[i]);
}
break;
I am sure this is easy but I’m having a mental block.
When the above Javascript outputs a drop down with the values from the array, it produces the following:
<option value="Perth">Perth</option>
<option value="Auckland">Auckland</option>
However, I really need the following:
<option value="1">Perth</option>
<option value="2">Auckland</option>
Where the value= number increments for all the options.
Any ideas?
Thanks,
H.
Looks like this call sets the values:
createOption(document.getElementById(q15), abc[i], abc.[i]);
So try changing either the first or second abc[i] to just i.