I have a jsp form which dynamically populates a <select> with existing roles, the code then creates corresponding hidden fields to hold the values of the select options as I cannot store the name of the option in the options value.
what I'm trying to do here is onChange in the select, I simply want to output the value of the hidden field value corresponding to the option within the select.
I am currently getting an "Expected ';'" at the
var myVal = eval("document.myForm." + i + ".value"
line every time this is executed.
Anyone have any ideas?
Thanks in advance.
The following is a snippet from my code:
function selectSalesOffice() {
for (i=0; i<document.myForm.EXISTINGROLES.length; i++) {
var myVal = eval("document.myForm." + i + ".value"
alert(myVal);
}
}
<form name=myForm>
<SELECT name=EXISTINGROLES onChange="selectSalesOffice();">
<OPTION value="notSelected"> Admin
<OPTION value="notSelected" selected> User
<OPTION value="notSelected"> Viewer
</SELECT>
<input type=hidden name=0 value=Admin>
<input type=hidden name=1 value=User>
<input type=hidden name=2 value=Viewer>
what I'm trying to do here is onChange in the select, I simply want to output the value of the hidden field value corresponding to the option within the select.
I am currently getting an "Expected ';'" at the
var myVal = eval("document.myForm." + i + ".value"
line every time this is executed.
Anyone have any ideas?
Thanks in advance.
The following is a snippet from my code:
function selectSalesOffice() {
for (i=0; i<document.myForm.EXISTINGROLES.length; i++) {
var myVal = eval("document.myForm." + i + ".value"
alert(myVal);
}
}
<form name=myForm>
<SELECT name=EXISTINGROLES onChange="selectSalesOffice();">
<OPTION value="notSelected"> Admin
<OPTION value="notSelected" selected> User
<OPTION value="notSelected"> Viewer
</SELECT>
<input type=hidden name=0 value=Admin>
<input type=hidden name=1 value=User>
<input type=hidden name=2 value=Viewer>