Hi I've a javascript function that hides or shows a DIV section on my web form, on page load the section is hidden but if the user checks a checkbox the section is displayed. This form has a few address fields that allow the user to search on street, town, post code etc by clicking a button and displaying any options in a datagridview where a record can be selected from to populate the necessary address fields. The thing is when the search button is clicked my <DIV> section is being hidden even though the checkbox is checked. How do I increment my numInt once the button has been clicked?
Here's my javascript function:
var numInt = 1;
function chckFrInt() {
if (numInt == 1) {
hideDiv()
}
}
function hideDiv() {
document.getElementById("divVisiting").style.display = "none";
}
</script>
</head>
<body onload="javascript:chckFrInt()">
<form id="frmServiceCallNew" runat="server">
I'm calling the javascript:chckFrInt function in the onload event. And the code behind one of the search buttons is:
<tr valign="middle">
<td align="right"><asp:Label ID="lblVisitingPostCode" runat="server" CssClass="Label_Small_Bold" Text="Postcode / Town:"></asp:Label></td>
<td align="left"><asp:TextBox id="txtVisitingPostCode" runat="server" CssClass="Input_Text_Long" MaxLength="50"></asp:TextBox>
<asp:TextBox ID="txtVisitingTown" runat="server" CssClass="Input_Text_Long" MaxLength="50"></asp:TextBox></td>
<td align="left"><asp:Button ID="btnSearchVisitingAddress" runat="server" Text="Search Address" CssClass="Button_XSmall" OnClick="btnSearchVisitingAddress_Click" />
<asp:Button ID="btnClearVisitingAddress" runat="server" Text="Clear" CssClass="Button_XSmall" OnClick="btnClearVisitingAddress_Click" />
</td>
</tr>
and the c# code:
protected void btnSearchAddress_Click(object sender, EventArgs e)
{
if (ServiceDB.getPostCodes(txtCustomerCountry.Text,
txtCustomerStreet.Text,
txtCustomerTown.Text,
txtCustomerPostcode.Text)
)
{
gvPostCodes.Visible = true;
gvPostCodes.DataSource = ServiceDB.dsResults.Tables["tbl_PostCodes"];
gvPostCodes.DataBind();
}
}
each time the page reloads numInt always = 1 therefore my
remains hidden even though the checkbox is checked.