A row in my ASP Table has 2 dropdownmenus (UCLSelector & LCLSelector) & 2 textboxes (UCLTextbox & LCLTextbox). Selecting "Not in List" in UCLSelector enables UCLTextbox & selecting "Not in List" in LCLSelector enables LCLTextbox. This part works fine.
I'm trying to:
- Compare the values between UCLSelector & LCLTextbox & prompt a message when the value in LCLTextbox > value in UCLSelector.
- Compare the values between LCLSelector & UCLTextbox & prompt a message when the value in LCLSelector > value in UCLTextbox.
- Compare the values between LCLTextbox & UCLTextbox & prompt a message when the value in LCLTextbox > value in UCLTextbox
1 & 2 are working fine. 3 does not work at all. The relevant HTML (ASP) & JS code is as follows. I've highlighted with comments where the code doesn't work. What could be causing this problem?
HTML
<asp:Table runat="server" ID="Table1" GridLines="Both">
<asp:TableRow>
<asp:TableCell ID="SelectCell1"><asp:CheckBox ID="ParamCheckBox1" runat="server"/></asp:TableCell>
<asp:TableCell ID="ParamCell1"/>
<asp:TableCell ID="LCLCell1"><asp:DropDownList ID="LCLSelector1" runat="server" onchange="checkLCLSel(1)"/></asp:TableCell>
<asp:TableCell ID="UCLCell1"><asp:DropDownList ID="UCLSelector1" runat="server" onchange="checkUCLSel(1)"/></asp:TableCell>
<asp:TableCell><asp:TextBox ID="LCLTextBox1" runat="server" onkeydown="validateNumber(event)" onfocusout="checkLCLTB(this,1)"/></asp:TableCell>
<asp:TableCell><asp:TextBox ID="UCLTextBox1" runat="server" onkeydown="validateNumber(event)" onfocusout="checkUCLTB(this,1)"/></asp:TableCell>
<asp:TableCell ><asp:Label ID="CharLabel1" runat="server" BorderStyle="None" Font-Bold="True" ForeColor="#FF3300"/></asp:TableCell>
</asp:TableRow>
</asp:Table>
JS
function checkLCLTB(currentTextBox, i) {
var LCLTBVal = currentTextBox.value;
var currentTextBoxId = currentTextBox.id;
var e = document.getElementById("UCLSelector" + i);
var strUser = e.options[e.selectedIndex].value;
//this part works fine
if (LCLTBVal > strUser && strUser != "Not in List") {
window.alert("Ensure LCL entered is less than UCL");
}
var f = document.getElementById("UCLTextbox" + i);
var UCLTBVal = f.value;
var g = document.getElementById("LCLSelector" + i);
var strUser2 = g.options[g.selectedIndex].value;
//this part does NOT work
if (strUser == "Not in List" && strUser2 == "Not in List") {
if (LCLTBVal > UCLTBVal) {
window.alert("LCL Message 1");
}
}
}
function checkUCLTB(currentTextBox, i) {
var UCLTBVal = currentTextBox.value;
var currentTextBoxId = currentTextBox.id;
var e = document.getElementById("LCLSelector" + i);
var strUser = e.options[e.selectedIndex].value;
//this part works fine
if (UCLTBVal < strUser && strUser != "Not in List") {
window.alert("Ensure UCL entered is greater than LCL");
}
var f = document.getElementById("LCLTextbox" + i);
var LCLTBVal = f.value;
var g = document.getElementById("UCLSelector" + i);
var strUser2 = g.options[g.selectedIndex].value;
//this part does NOT work
if (strUser == "Not in List" && strUser2 == "Not in List") {
if (UCLTBVal < LCLTBVal) {
window.alert("UCL Message 1");
}
}
}