I have been having some trouble with short names, so this example uses fully qualified names.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!-- Do the same thing for each of three elements -->
var state;
function toggle() {
if (state) {
document.forms[0].myText.value = "Hi, Duke!";
document.forms[0].myImage.src = "duke.wave.shadow.gif";
document.forms[0].myButton.value = "True";
state = false;
} else {
with (document.forms[0]) {
myText.value = "This is Duke.";
myImage.src = "duke.gif";
myButton.value = "False";
}
state = true;
}
}
<!-- Do something different for the fourth element -->
var flipState = true;
function flip(what) {
flipState = !flipState;
what.value = (flipState ? " On " : " Off ");
}
</script>
</head>
<body bgcolor="#FFFFFF">
Click on anything...
<form method="post" action="">
<input type="text" name="myText" value="This is Duke." onClick="toggle();">
<img src="../duke.gif" width="55" height="68" name="myImage" onClick="toggle();">
<input type="button" name="myButton" value="Button" onClick="toggle();">
<input type="button" name="OnOffButton" value="On" onClick="flip(this);">
</form>
<table width="100%" border="1" cellspacing="0" cellpadding="8">
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
|