CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Javascript: check to see if textbox is empty in a panel

Print topic Send  topic

Author Message
Chris__T


Posts: 339
Posted: 12/01/2008, 2:43 PM

Basically, I have a textbox inside a panel. Right now, the page loads with the panel not being displayed:

  
var panel = document.getElementByID('Panel1');  
		panel.style.display = 'none';  


I would like it to be visible (on page load) only if there is something in the textbox. I'm using this code:

  
var notempty = document.getElementById('textbox1');  
if (notempty.value == "") {  
   var panel = document.getElementById('Panel1');  
   panel.style.display = 'none';  
}  
But it doesn't do anything. Any suggestions would be appreciated.
View profile  Send private message
Chris__T


Posts: 339
Posted: 12/03/2008, 9:49 AM

I've also tried this:

  
panel=document.getElementById('Panel_Footing');  
if (document.permit7.Inspector3.value.length > 1)  
{  
	panel.style.display = 'block';  
}  
else  
{	  
	panel.style.display = 'none';  
}  

But nothing.
View profile  Send private message
peterr


Posts: 5971
Posted: 12/03/2008, 11:02 AM

This may depend on where you are placing this code. It probably cannot be textbox event, but possibly panel or page event.

Also, this could be a logical issue: how can you paint a box black or white depending on what's inside, if you don't know what's inside?
Translation: If there is a value in a textbox then it's because the panel is visible, so it's too late too hide it. While if the panel is hidden then it may not know what's inside the textbox and cannot make itself visible.
Not sure if this is the case, but I wouldn't be surprised if it is.

It may be better to do some lookup directly from the database and then decide if you want to hide or display the panel.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Chris__T


Posts: 339
Posted: 12/03/2008, 12:05 PM

Ah, I get it. If the panel is not visible, then the code won't see what's inside. And since my panel is hidden by default when the page loads, the javascript can't see what the textbox holds. Thanks for the explanation, Peter. I wasn't catching that. :)

Ok, so check the database directly (dlookup perhaps) and see if this record 's field for the textbox is empty or not, then do the visible/hidden. Sounds like this would work better server side (vbscript) rather than client-side (javascript)

Thanks.
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.