Is there a way to automatically disable all text boxes if any one of them has a value? I have an array of cost types and their associated costs. If a cost is entered for any type, all other text boxes for cost types should be disabled. If no cost is entered, all text fields should remain editable. I've attempted to use the following code without success.
function stoppedTyping(iVal){
var costs=document.getElementsByName("cost")[iVal].value;
if(costs > 0) {
document.getElementById("cost_" + iVal).disabled=true;
} else {
document.getElementById("cost_" + iVal).disabled=false;
}
}
<td colspan="4">
<input type="text" size="10" maxlength="8" name="cost" id="cost_<c:out value="${y}"/>" value="<c:out value="${costDto.cost}"/>"
onBlur=" stoppedTyping(<c:out value="${y}"/>)"; "/>
</td>