Closed Thread Icon

Preserved Topic: problems w/css properties using JS (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=18027" title="Pages that link to Preserved Topic: problems w/css properties using JS (Page 1 of 1)" rel="nofollow" >Preserved Topic: problems w/css properties using JS <span class="small">(Page 1 of 1)</span>\

 
phortay
Bipolar (III) Inmate

From: the_phortarium
Insane since: May 2001

posted posted 06-15-2001 06:53

I pulled this code out of the book I'm learning JavaScript from. Problem is that it doesn't work in my browser. I'm using IE 5.5. I wrote the code, saved it as a html file, opened it , and....nothing!

Can someone please check my code

<html>
<head>
<title>Controlling Styles with JavaScript</title>
<script language="Javascript">
function changehead() {
i = document.form1.heading.selectedIndex;
headcolor = document.form1.heading.options[i].value;
document.getElementById("head1").style.color = headcolor;
}
function changebody() {
i = document.form1.body.selectedIndex;
doccolor = document.form1.body.options[i].value;
document.getElementById("p1").style.color = doccolor;
}
</script>
</head>
<body>
<h1 ID="head1">Controlling Styles with JavaScript</h1>
<hr />
<p ID="p1">
Select the color for paragraphs and heading using the form below.
The colors ;you specified will be dynamically changed in this document.
The change occurs as soon as you change the value of either of the
drop-down lists in the form.
</p>
<FORM NAME="form1">
<B>Heading Color: </B>
<select name="heading" onChange="changehead();">
<option value="black">Black</option>
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
<option value="yellow">Yellow</option>
</select>
<br />
<B>Body Text Color: </B>
<select name="Body" onChange="changebody();">
<option value="black">Black</option>
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
<option value="yellow">Yellow</option>
</select>
</FORM>
</body>
</html>

responses appreaciated in advance

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 06-15-2001 07:38

Well, the header part works fine.

For the body, change
<select name="Body" onChange="changebody();">
to
<select name="body" onChange="changebody();">

Note that "body" is no longer capitalized.

That seems to work for me in IE 5.5

phortay
Bipolar (III) Inmate

From: the_phortarium
Insane since: May 2001

posted posted 06-15-2001 08:36

thanks for the help...it works fine now...I really appreciate it

~phortay~

« BackwardsOnwards »

Show Forum Drop Down Menu