I am doing something wrong.
html:
JavaScript
x
3
1
Quantity: <input type = "text" id ="quantc" name = "quantWash" size = "5" tabindex = "13" onblur="calcRowWash()"/><br>
2
Wash Total: <input type = "text" id ="totc" name = "washtotal" size = "5" tabindex = "14" value=""/>
3
js:
JavaScript
1
13
13
1
calcRowWash = (function(){
2
var x = document.getElementById("quantc");
3
4
if(x == "2"){
5
document.getElementById("totc").value = 1000;
6
}else{
7
document.getElementById("totc").value = 100;
8
}
9
10
});
11
12
13
Advertisement
Answer
There you go, it is working now. As mentioned by Alon, you were comparing the element itself (#quantc
) instead of its value
JavaScript
1
9
1
calcRowWash = (function(){
2
var x = document.getElementById("quantc").value;
3
if(x == "2"){
4
document.getElementById("totc").value = 1000;
5
}else{
6
document.getElementById("totc").value = 100;
7
}
8
9
});
JavaScript
1
2
1
Quantity: <input type = "text" id ="quantc" name = "quantWash" size = "5" tabindex = "13" onblur="calcRowWash()"/><br>
2
Wash Total: <input type = "text" id ="totc" name = "washtotal" size = "5" tabindex = "14" value=""/>