Welcome to WebmasterWorld Guest from 184.108.40.206 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
New to JS and can't see what error Ive made here/why it isn't working. Note, i originally used eval in the onclick function but someone told me i didn't need it. Didn't work with that either.........
<head> <title>Objects, methods and events.</title>
<!-- hide var user=prompt("Hello! What is your name?"); var outputString="Nice to meet you "+user+"! Welcome to my page"; alert(outputString);
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>");
you mixed some
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
You win't see anything in Netscape either because you are using form elements (input) without a form tag.
IE will allow this, but Netscape won't.
Put in some form tags and you'll be closer.
Put in some form tags and you'll be closer. form tags are placed. see the code.
the choice for netscape was about the
txbakers, i think you've mixed it up a bit... ;)
ah yes I see, sorry about that. too sleepy. too much coding. must rest.