[thelist] Javascript + CSS Magic to "reveal" form field
Jono
ox4dboy at comcast.net
Wed Aug 18 10:48:15 CDT 2004
I have moved on to what appears to be a better option, problem is that this
JS is supposed to be used on a link. I need this to work on a checkbox.
Below is the code I am trying, and below that is my code, and the errors I
am getting:
[quote: code I am trying to use]
Try this function - best ive found and its good cross browser compatibility:
<!-- in HEAD of document -->
<script language="javascript">
<!--
var state = 'hidden';
function showhide(layer_ref) {
if (state == 'visible') {
state = 'hidden';
}
else {
state = 'visible';
}
if (document.all) { //IS IE 4 or 5 (or 6 beta)
eval( "document.all." + layer_ref + ".style.visibility = state");
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[layer_ref].visibility = state;
}
if (document.getElementById && !document.all) {
maxwell_smart = document.getElementById(layer_ref);
maxwell_smart.style.visibility = state;
}
}
//-->
</script>
<!-- in BODY of document -->
<div id="agent99" style="position:absolute; top:103px; left:153px;
visibility:hidden;">
your stuff to show here
</div>
<!-- CLICK LINK TO SHOW LAYER -->
<a href="javascript://" onclick="showhide('agent99');">click me</a>
[/quote]
[snip of my code]
<tr>
<td> </td>
<td> </td>
<!-- This checkbox should show/hide the div "aggent99" -->
<td><input name="addName" type="checkbox" id="addName" value="addName"
"onclick="showhide('agent99');"><label for="addName">[Add your
Name]</label></td>
<td> </td>
</tr>
<div id="agent99" style="visibility: hidden;">
<tr>
<td> </td>
<td><label for="Name">Name</label></td>
<td><input name="Name" type="text" value="" id="Name" size="32"></td>
<td> </td>
</tr>
</div>
[/snip]
This is the error that Firefox is reporting:
Error: uncaught exception: [Exception... "Component returned failure code:
0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsILocalFile.initWithPath]"
nsresult: "0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)" location: "JS
frame :: chrome://browser/content/search.xml :: initialize :: line 31"
data: no]
Can someone please help me to get this working?
More information about the thelist
mailing list