View Single Post
Old 12-02-2012, 05:00 PM   PM User | #1
janehollin
New to the CF scene

 
Join Date: Nov 2012
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
janehollin is an unknown quantity at this point
Hide div if ASP text box IsNull (OnPageLoad)

Hi

Sorry if this is a double posting - I think I have deleted the text from the other (same) question. Not sure how I did that ??

I know this can be done with VB - something like this
Code:
If Not String.IsNullOrEmpty(Request.Form("SOME TEXT BOX NAME")) Then
strSOME OTHER NAME = Request.Form("SOME TEXT BOX NAME")
This can be to indiv boxes or whole divs.
But I am looking for a faster load and I think JS would not need to iterate though the whole form, and this is why I need to help with the JS

What I am trying to do is to set the Display:None or Display:Block of a div OnPageLoad, but this is dependant upon if a certain ASP:TextBox in the div contains data or IsNull.

Hope that make sense.

So, as an example, in this case
MyDiv1 would be style="display:none" as it is not null
MyDiv2 would be style="display:block" as it is null
MyDiv3 would be style="display:none" as it is not null
MyDiv4 would be style="display:block" as it is null

Note that the textboxes are always called MyTextBox + #

Code:
<body>

<div id="FormHolder">
	<form id="MyForm">
		<div id="MyDiv1">
			<asp:TextBox id="MyTextBox1" runat="server">Some text</asp:TextBox>
		</div>
		<div id="MyDiv2">
			<asp:TextBox id="MyTextBox2" runat="server"></asp:TextBox>
		</div>
		<div id="MyDiv3">
			<asp:TextBox id="MyTextBox3" runat="server">Somthing</asp:TextBox>
		</div>
		<div id="MyDiv4">
			<asp:TextBox id="MyTextBox4" runat="server"></asp:TextBox>
		</div>
	</form>
</div>

</body>
Thanks if you can help
janehollin is offline   Reply With Quote