473,657 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot Hide layer when text length is zero? Help!

I am trying to hide a layer when a text box length is zero, and its
just not working! It hides the content in the layer, but you still
see a little 2 pixel width blip on the screen. I've spent hours
playing with stuff, its a brain cramp. Need someone to state the
obvious for me. Heres my code.....
<style type="text/css" media="screen">
#search_suggest {
position: absolute;
background-color: #FFFFFF;
text-align: left;
border: 1px solid #3366CC;
}
</style>

<script language="javas cript" type="text/javascript">

function OneStrcZeroLeng th(thelayer){
if ( document.getEle mentById('txtSe arch').length == 0){
thelayer.style. display='none';
}
}
</script>
<form id="frmSearch" >
<input type="text" id="txtSearch" name="txtSearch " alt="Search
Criteria" onkeyup="search Suggest();"
onkeydown="OneS trcZeroLength(d ocument.getElem entById('search _suggest'));"
autocomplete="o ff" />

<input type="submit" id="cmdSearch" name="cmdSearch " value="Search"
alt="Run Search" /><br />
<div id="search_sugg est">
</div>
</form>

As you can see from the code, ONKEYDOWN for textbox "txtSearch" , it
calls function OneStrcZeroLeng th, which then checks to see if
txtSearch has a zero length, and if it does, it tells the layer style
to change to display none.

Which it doesn't do. Ive done numerous things to try to correct this,
but to no avail. Any ideas?

Thanks!
JE

Jun 18 '07 #1
5 1540
JEgbert <jo**@onestruct ure.comwrote in news:1182203250 .592225.115890
@w5g2000hsg.goo glegroups.com:
I am trying to hide a layer when a text box length is zero, and its
just not working! It hides the content in the layer, but you still
see a little 2 pixel width blip on the screen. I've spent hours
playing with stuff, its a brain cramp. Need someone to state the
obvious for me. Heres my code.....
I could be totally wrong, but maybe two things?

a) could the blip be the 'remnants' of the text cursor? it seems like
you'd be hiding a DIV that has an active, flashing 'text input' cursor.
maybe its a screen redraw issue. try taking the focus() off the
layer/field first?

b) im assuming this isn't it, because you can get '0' right now, but
shouldnt it be:

if ( document.getEle mentById('txtSe arch').value.le ngth == 0) ??

(i added 'value'.. mentally i imagine that getElementById
('textSearch'). length is the length of the DOM element, not the field
value. obviously i haven't executed your code)

:)

good luck

Jun 18 '07 #2

JEgbert wrote:
I am trying to hide a layer when a text box length is zero, and its
just not working! It hides the content in the layer, but you still
see a little 2 pixel width blip on the screen. I've spent hours
playing with stuff, its a brain cramp. Need someone to state the
obvious for me. Heres my code.....

try:
<script type="text/javascript">
function OneStrcZeroLeng th(txtSearch,th elayer){
if (!txtSearch.val ue.length)
thelayer.style. display='none';
}
</script>
<form id="frmSearch" >
<input
type="text"
id="txtSearch"
name="txtSearch "

onkeyup="search Suggest();OneSt rcZeroLength(th is,document.get ElementById('se arch_suggest')) ;"
/>

<div id="search_sugg est"></div>
</form>

Jun 19 '07 #3
hey guys,
Thanks for the shot.. unfortunately it didnt work, but I know why.....

it DOES hide the layer, but not the layer border. The border still is
1px, regardless of the info in the layer being hidden. if I take out
the border it works.

But I need the border :-) How would I dynamically hide the border?
JE

Jun 19 '07 #4
SPOKE TOO SOON. IT DOESNT WORK. forget everything I just said. none
of this is even hiding anything. Just put some content in the
search_suggest div and check it out for yourself.

Jun 19 '07 #5
JEgbert <jo**@onestruct ure.comwrote in news:1182282091 .816991.260250
@q75g2000hsh.go oglegroups.com:
SPOKE TOO SOON. IT DOESNT WORK. forget everything I just said. none
of this is even hiding anything. Just put some content in the
search_suggest div and check it out for yourself.
the code i provide at the end of this post works for me.

i left the "alert" in the function so you can see whats happening. You
ignored my earlier suggestion to leave "value" in there - i put it in
because you weren't checking for the value's length.

I changed the CSS to make it very apparant that the DIV is hiding
correctly.

Also, you were calling searchSuggest as a function which wasn't in the
code until I put something blank in.

Also, i don't know if you REALLY want to be calling your functions when
you do (onkeydown) because you have a fundamental flaw in your logic.
When i want to enter a character in your text box, you're calling the
function before my character is entered, so it reports '0' as the length
even though i just typed a character. Change it to "onkeyup", or better
yet, combine your function into the function searchSuggest.

Surely you can take it from here... after you buy me a beer.

**

<html>
<head>
<style type="text/css" media="screen">
#search_suggest {
position: absolute;
background-color: #FFFFFF;
text-align: left;
border: 1px solid #3366CC;
width: 200px;
height: 400px;
}
</style>

<script language="javas cript" type="text/javascript">

function OneStrcZeroLeng th(thelayer){
//note that you must have 'value' in there!!!
var dox = document.getEle mentById('txtSe arch').value.le ngth;
alert(dox); //see what happens if 'value' is removed for proof
if (dox == 0){
thelayer.style. display='none';
}
}

function searchSuggest() {
//nothing to see here
}

</script>

</head>
<body>

<form id="frmSearch" >
<input type="text" id="txtSearch" name="txtSearch " alt="Search
Criteria" onkeyup="search Suggest();"
onkeydown="OneS trcZeroLength(d ocument.getElem entById
('search_sugges t'));"
autocomplete="o ff" />

<input type="submit" id="cmdSearch" name="cmdSearch " value="Search"
alt="Run Search" />
<br />
<div id="search_sugg est"></div>

</form>

</body>
</html>
Jun 19 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
14433
by: Ryh | last post by:
I have the following scritpt. It hides div layer when mouse is out of the div layer. Inside DIV I have IFRAME box. Unfortuantely it does not work in Mozilla or IE 5.5. It hides div when cursor is inside IFRAME. NOte that IFRAME is inside DIV so it should not hide DIV. It Works fine in IE6.0. Could any one help? Example:
8
5463
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
0
391
by: John Mason | last post by:
Hi, I have developed an asp.net application that uses forms authentication. I have a local install and a remotely hosted install of the application. Intermittently the remote application falls over with an error (see below for details). This seems to happen on different pages after an asp forms button is clicked, and brings down the whole application when it does happen. When it happens you cannot browse to any page within the...
3
6390
by: Merlin | last post by:
Hi there, I am trying to create a form with an dynamic field that can be shown or hidden. As I saw for example on google it is possible with JS to show a layer and move the content underneath that layer further down uppon showing this layer. When a person closes that layer the content underneath the layer moves up again and closes the empty space. How is this possible? I am playing around with some code I am posting with this thread....
2
3432
by: =?Utf-8?B?cmVk?= | last post by:
Hi Friends, We recently deployed our application to production and I am experiencing the below error message. Cannot access a disposed object named "System.Net.TlsStream" The error occurs when we are making a web service call to an external system (within our corporate n/w). The method is POST and the URL is over HTTPS.
1
1217
by: JEgbert | last post by:
I built a dynamic ajax suggest engine, and you would think I could figure this out, but I am having a brain cramp. When I don't have any characters in the search box, it shows a little blip of the layer where the suggestion results go... How do I make this go away? Something along the lines of if ( document.getElementById('txtSearch').length == 0){ thelayer.style.display=(thelayer.style.display=="none"); }
1
4164
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. I don`t want to change the way i have used to show and hide layers. check down code :- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html...
3
11214
by: Coll | last post by:
I inherited a database. On one of the forms, a bunch of fields on the form are to be updated with data from a combo box containing many columns after one particular field is updated. I'm receiving an error message "Field cannot be a zero length string." I do have some records with null values for a few fields - no way around that. How can I prevent the error message from occurring? Here's a sample of the code... Me! = Me!.Column(9) Me!...
12
2156
by: Kevin Blount | last post by:
I'm having a very odd issue, that arose this morning after working fine yesterday... here's a very simple script: 1: <?php 2: $test = $_GET; 3: echo "Hello" . $test . "<p>"; 4: ?>
0
8411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8323
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.