Showing n Hiding DIV LAYER through JAVSCRIPT?

laksh_khamesra

New Member
I want a div layer to appear when focused and disappear when blurred.
So I called 2 functions through events in the input.

The input code is like this:--
HTML:
<input type="text" name="username" id="username" onfocus="show_div('apDiv1')" onblur="hide_div('apDiv1')" />


And the javascript code is like this:--
HTML:
<script language="javascript">
function show_div(div_id)
{
document.all.div_id.style.visibility = "visible";
}

function hide_div(div_id)
{
document.all.div_id.style.visibility = "hidden";
}
</script>

And the div layer's code is like this:--
HTML:
<div id="apDiv1">Username can contain only numbers and letters.</div>
 

jnjc

New Member
Change your JS code to:


Code:
<script  type="text/javascript">
function show_div(div_id)
{
document.getElementById(div_id).style.visibility = "visible";
}

function hide_div(div_id)
{
document.getElementById(div_id).style.visibility = "hidden";
}
</script>

HTH,
JC
 
Top