PDA

View Full Version : Resolved js doesnt work in firefox but does in IE?



thedash
05-20-2009, 05:35 AM
hey guys, just trying to make a simple script that when you check a checkbox it shows a <div> i created. There is some customization: it only shows the div if you go from an unchecked to a checked state, and if you hit a "cancel" button it unchecks the box again. Works perfectly in IE, but the <div> doesn't get shown at all in firefox...???



<script type=text/javascript>
<!--
function showMe(id, chkbox)
{
var obj2 = document.getElementById(chkbox);
if (obj2.checked == true)
{
var obj = document.getElementById(id);
if (obj.style.visibility=="hidden")
{
obj.style.visibility = "visible";
}
else
{
obj.style.visibility = "hidden";
}
}
}

function submitMe(id)
{
var obj = document.getElementById(id);
obj.style.visibility = "hidden";
}

function cancelMe(id,chkbox)
{
var obj = document.getElementById(id);
obj.style.visibility = "hidden";

var obj2 = document.getElementById(chkbox);
obj2.checked = false;
}

//-->
</SCRIPT>

<div id="my_div" style="position:absolute; z-index: 1; top: 0%; left: 50%; visibility: hidden; width: 450px; height: 200px; border:1px solid #3F3F3F; background-color: #fffecd;">
<font face=verdana size=3><center> LOGIN INFORMATION </center></font>
<br><br><br>
<table width=50% align=center>
<tr>
<td width=40%>
<font face=verdana size=1>username:</font>

</td>
<td width=60%>
<input type="text" name="username" size="50" style="font-family:Verdana; font-size:11; border-width:1; border-color: #000000; border-style:solid;">
</td>
</tr>
<tr>
<td width=40%>
<font face=verdana size=1>password:</font>

</td>
<td width=60%>
<input type="password" name="password" size="50" style="font-family:Verdana; font-size:11; border-width:1; border-color: #000000; border-style:solid;">
</td>
</tr>
</table>
<br><br>
<center><input type="image" src="http://www.tech-area.com/files/submit.jpg" onclick="submitMe('my_div');" border=0><font color=#fffecd>.......</font><input type="image" src="http://www.tech-area.com/files/cancel.jpg" onclick="cancelMe('my_div', 'mybox');" border=0>
</div>



<form name="myform">
<center><input type="checkbox" name="mybox" onclick="showMe('my_div', 'mybox');" value="Show Active">Show Hide Checkbox
</form>

vwphillips
05-20-2009, 09:51 AM
<form name="myform">
<center><input type="checkbox" id="myspacebox" name="myspacebox" onclick="showMe('myspace_div', 'myspacebox');" value="Show Active">Show Hide Checkbox
</form>

thedash
05-20-2009, 04:27 PM
oh my god i knew it was something dumb i'd done. thank you !