Forum Moderators: open
<html>
<head>
<title>Objects, methods and events.</title>
</head>
<body bgcolor="red">
<script language="JavaScript">
<!-- hide
var user=prompt("Hello! What is your name?");
var outputString="Nice to meet you "+user+"! Welcome to my page";
alert(outputString);
var silvervar="silver"
var whitevar="white"
var resetvar="#cccc99"
//close hide -->
document.write("<form><input type='button' value='Silver' onClick='document.bgColor='silvervar'></form>");
document.write("<form><input type='button' value='White' onClick='document.bgColor='whitevar'></form>");
document.write("<form><input type='button' value='reset' onClick='document.bgColor='resetvar'></form>");
</script>
</body>
</html>
you mixed some 'ses:
document.write("<form><input type='button' value='Silver' onClick='document.bgColor='silvervar'></form>");
...
use this instead:
document.write("<form><input type='button' value='Silver' onClick='document.bgColor='"+silvervar+"'></form>");
...
you need to insert the vars into the string. this won't work autmatically. so a + is used to connect strings.
tip: having problems in such cases use netscape and viewsource to see the javascript generated sourcecode.
Put in some form tags and you'll be closer.
the choice for netscape was about the viewsource command. this will display not the source of the page like retrieved, it will display the source of the page after javascript changed the document content with these changes. so it count nothing if a form tag would have been obmitted.
txbakers, i think you've mixed it up a bit... ;)