I’m trying to call javascript by clicking on the image but it’s not working.
Please refer below for my code.
Javascript
<script type="text/javascript">
<!--
var image1=new Image()
image1.src="images/Image_1.png"
var image2=new Image()
image2.src="images/Image_2.png"
var image3=new Image()
image3.src="images/Image_3.png"
//-->
function login(showhide){
if(showhide == "show"){
document.getElementById('popupbox').style.visibility="visible";
}else if(showhide == "hide"){
document.getElementById('popupbox').style.visibility="hidden";
}
}
</script>
my code
<div id="apDiv21"><img src="images/Login_OnOut.png" width="71" height="44"
onmouseover="this.src='images/Login_OnRollover.png'"
onmouseout="this.src='images/Login_OnOut.png'" onclick="login('show');" />
<div id="popupbox">
<form name="login" action="" method="post" style="background-color:#C7C7C7">
<center>Username:</center>
<center><input name="username" size="14" /></center>
<center>Password:</center>
<center><input name="password" type="password" size="14" /></center>
<center><input type="submit" name="submit" value="login" /></center>
</form>
<center><a href="login('hide');">close</a></center>
</div>
Check out this JSFiddle I made:
http://jsfiddle.net/Q5asp/
I changed the link at the bottom to properly hide it. The problem was that when you used
Login('show')it was trying to access your form because it was the same name. You must make sure that your function name and names don’t conflict.