Click to See Complete Forum and Search --> : help me


xdef
03-02-2003, 11:22 PM
Why doesn't this work?
Is there something missing? I can't see any ommisions.
thanks
xdef


<html>
<head>
<title>Objects, methods and events.</title>
</head>


<body bgcolor="#333333">
<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"
document.write("<form><input type='button' value='Silver' onClick=eval('document.bgColor='silvervar')></form>");
document.write("<form><input type='button' value='White' onClick=eval('document.bgColor='whitevar')></form>");
document.write("<form><input type='button' value='reset' onClick=eval('document.bgColor='resetvar')></form>");
//close hide -->
</script>

</body>
</html>

khalidali63
03-03-2003, 12:25 AM
Here you go..you did not need to use the eval function there


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>");


Hope this helps

Khalid

xdef
03-03-2003, 12:38 AM
Nope. It still isn't working for me without the eval function.

khalidali63
03-03-2003, 12:46 AM
Then there is something other then the code you posted that is causing the problem.
I have tested the above piece on NS6+/IE6 browsers on Win2k platform..
I can post a link of working code example iof you want to see it..

:D

Cheers

Khalid

xdef
03-03-2003, 01:29 AM
thank you if you could post a working eg that would be helpful.

khalidali63
03-03-2003, 01:32 AM
Here you go,

http://68.145.35.86/temp/BGProblem.html

Hope this helps

Khalid

xdef
03-03-2003, 02:02 AM
yes Khalid it is working now. A problem I had was this:

onClick='document.bgColor=silvervar'></form>");

but in the original (b4 u changed it)

onClick='document.bgColor='silvervar'></form>");

this tiny slip!

Thanks 4 your help