Wondering if anyone could help with the following code. I have a combobox called "cboAgreement"
which is a dropdown with two values "Agree"
and "Disagree"
.
I have a form where, the comments grid is initially hidden, but when a user chooses "Disagree"
the comments grid should appear.
When i inspect the webpage, it gives back this error:
"Uncaught TypeError: Cannot read property 'value' of null"
I have tried changing the if statement to decision.getvalue()
but again same thing.
<script type="text/javascript">
var commentsGrid = document.getElementById("comms");
var decision = document.getElementById("cboAgreement").value;
commentsGrid.style.visibility = "hidden";
if (decision == "Disagree") {
commentsGrid.style.visibility = "visible";
}else{
commentsGrid.style.visibility = "hidden";
}
</script>
and the combo box is as follows:
<sq8:ComboBox runat="server" ID="cboAgreement"><Items>
<sq8:ComboBoxItem runat="server" Text="Agree" Selected="True"></sq8:ComboBoxItem>
<sq8:ComboBoxItem runat="server" Text="Disagree"></sq8:ComboBoxItem>
</Items>
</sq8:ComboBox>
<sq:BindableControl runat="server" TargetControlID="cboAgreement" DataField="cboAgreement"></sq:BindableControl>
What am i doing wrong? I should say, I'm new to JavaScript so 99.9% doing something incorrect!
Thanks in advance for any help.