Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Feedback: irt.org FAQ Knowledge Base Q984

Feedback on:
irt.org FAQ Knowledge Base Q984

Sent by Kevin Lynn Brown on June 14, 2000 at 20:49:39: - feedback #1370

Comments:
This article has syntax and code errors.

if (toggle = !toggle)

...doesn't look like a valid comparison to me. Shouldn't this be

if (toggle == true)

Additionally, at no time during the script is toggle set to true, therefore the hide() function will never be called.

Hope this helps,
Kevin



Sent by Dimitris Anthoulakis on October 04, 2002 at 05:44:47: - feedback #4194

Worth:
Very worth reading

Comments:
Here is another version of the javascript, that also changes the title of the button to "Show" and "Hide" each time the user clicks on it.

<html>
<head>
<title></title>
</head>
<body bgcolor="#ffffff">
<SCRIPT LANGUAGE=JavaScript>
var toggle = true;
function show(object) {
window.document.form2.myButton.value = 'Hide';
if (document.layers && document.layers[object])
document.layers[object].visibility = 'visible';
else if (document.all) {
document.all[object].style.visibility = 'visible';
document.all[object].style.zIndex = 100;
}
}
function hide(object) {
window.document.form2.myButton.value = 'Show';
if (document.layers && document.layers[object])
document.layers[object].visibility = 'hidden';
else if (document.all)
document.all[object].style.visibility = 'hidden';
}
</SCRIPT>
<form NAME=form2>
<input type="button" NAME="myButton" onClick="if (toggle = !toggle) hide('myId');else show('myId')" value="Show">
</form>
<div id="myId" style="position: absolute; visibility: hidden;">TestTestTestTestTestTestTestTestTestTest</div>
</body>
</html>



Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 21st December 2007. Maintained by: Martin Webb
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.