Im currently designing a JSP, which has some javascript embedded. What i am trying to do, is disable a button, if a user selects a particular row from the drop down list.
At the moment, within the select tag, the value of a variable (called Status) is queried to find out which option should have the <option selected> tag by it.
The problem is every time onchange gets run, i get an error saying that ‘selectedindex’ is undefined.
Any ideas?
<% String status = DLPULGA3Bean.getStatus(); %>
function checkIfAll()
{
if (window.document.DLPULGA3form.statusValue.options[selectedIndex].value == "All")
{
window.document.DLPULGA3form.Find.disabled = true;
}
else
{
return false;
}
}
<select name="statusValue" onChange="checkIfAll()">
<% if (status.equals("Accepted")) {%>
<option selected>Accepted</option>
<option value ="Rejected">Rejected</option>
<option value ="Proposed"> Proposed</option>
<option value ="All">All</option>
<% } else if (status.equals("Rejected")) {%>
<option value ="Accepted">Accepted</option>
<option selected>Rejected</option>
<option value ="Proposed">Proposed</option>
<option value ="All">All</option>
<% } else if (status.equals("Proposed")) {%>
<option value ="Accepted">Accepted</option>
<option value ="Rejected">Rejected</option>
<option selected>Proposed</option>
<option value ="All">All</option>
<% } else { %>
<option value ="Accepted">Accepted</option>
<option value ="Rejected">Rejected</option>
<option value ="Proposed">Proposed</option>
<option selected>All</option>
<% } %>
</select>