I am trying for a week that, Scenario: The table Alphabet having 3 values with two columns ID Alphabet 1 A 2 B 3 C
This values are pulling by java code which shows in JSP as Dropdown. If user typed 2 in another textbox and submit. Automatically the Alphabet dropdown will select B and visible in dropdown. It should match the user typed value with the Dropdown ID and It should select B automatically in the dropdown.
JSP
<html:text property="usergivenID" name="alphaForm"/> <td>
<html:select property="alphaId" name="alphaForm" onchange="automate();">
<html:option value=''><bean:message key="default.dropDownValue"/></html:option>
<html:options collection="alpList" name="form" property="label" labelProperty="value" />
</html:select></td>
function automate(){
var options = document.forms[0].usergivenID.value;
var opt=document.forms[0].alphatId.option;
for (var i = 0; i < options.length; i++) {
if (options[i].text == document.forms[0].alphaId.option) {
opt[i].selcted=true;
break;}
}
}
Eg: If user gives 3 in usergivenID it should compare whit the alphabetID and should select B automatically.The above code I tried but ist not working