Click to See Complete Forum and Search --> : I think this is very easy...


stalepretzel59
05-03-2006, 11:49 AM
This is a simple page: Click the button, confirm you want to learn a secret, and get alerted OMFG. Also, below the button, is some text which says "click." Clicking it should make the first button appear and disappear... but it does not! <thickAccent>I could spit!</thickAccent>
Anyway, here's the code.. could somebody help me?<html>
<head>
<script type="text/javascript">

function wowow(){
document.getElementById('right').classValue="show"
document.getElementById('mkay').onClick="oman()"
}
function oman(){
document.getElementById('right').classValue="hide"
document.getElementById('mkay').onClick="wowow()"
}
function secret()

{
var name=confirm("Are you SURE you want"+'\n'+" to know the secret?")
if (name==true)
{
alert("OMFG")
}
else
{}
}
</script>
</head>
<body>
<style type="text/css">
.hide{display:none}
.show{display:inline}
</style>
<body bgcolor="#339966">
<br /><br /><br /><br /><br /><br /><br />
<div align="center">
<form>
<input type="button" id="right" name="right" onclick="secret()" value="Click this button to learn a secret...">
</form>
<label id="mkay" onClick="oman()">Click</label>


</div>
</body>

</html>

TheBearMay
05-03-2006, 12:50 PM
Change classValue to className...

Charles
05-03-2006, 01:07 PM
And onCLick to onclick and assign the function and not the value returned by the function.

stalepretzel59
05-05-2006, 12:02 PM
what do you mean, Charles?
... and assign the function and not the value returned by the function.

Charles
05-05-2006, 12:51 PM
document.getElementById('mkay').onclick = "oman()" assigns a string,"oman()", which isn't very useful.

document.getElementById('mkay').onclick = oman() calls the function oman() and assigns what is returned, which is undefined, and which isn't very useful.

document.getElementById('mkay').onclick = oman assigns the value of oman, which is a function, and which is exactly what you want.

stalepretzel59
05-08-2006, 11:56 AM
Muchas gracias, Charles.
///Webdeveloper.com is my home dawg///