Cannot Hide layer when text length is zero? Help!

J

JEgbert

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="javascript" type="text/javascript">

function OneStrcZeroLength(thelayer){
if ( document.getElementById('txtSearch').length == 0){
thelayer.style.display='none';
}
}
</script>


<form id="frmSearch">
<input type="text" id="txtSearch" name="txtSearch" alt="Search
Criteria" onkeyup="searchSuggest();"
onkeydown="OneStrcZeroLength(document.getElementById('search_suggest'));"
autocomplete="off" />

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


<div id="search_suggest">
</div>
</form>



As you can see from the code, ONKEYDOWN for textbox "txtSearch", it
calls function OneStrcZeroLength, 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
 
S

scripts.contact

JEgbert said:
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 OneStrcZeroLength(txtSearch,thelayer){
if (!txtSearch.value.length)
thelayer.style.display='none';
}
</script>


<form id="frmSearch">
<input
type="text"
id="txtSearch"
name="txtSearch"

onkeyup="searchSuggest();OneStrcZeroLength(this,document.getElementById('search_suggest'));"
/>

<div id="search_suggest"></div>
</form>
 
J

JEgbert

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
 
J

JEgbert

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top