This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-04-17 20:15:42

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

JavaScript Problem.

Problem with code I can't figure out  hmm

Code:

<!DOCTYPE html>
<head><title>Worldz!</title><style type="text/css">
button{
border: 1px #000099 solid;
background-color: blue;
width: 98%;
height: 50px;
}
h1{
text-align: center;
}
body{
background-color: grey;
background-image: none;
}
p{
color: #000;
font: arial;
align:center;
}
#plan{
background-color: #3399FF;
font: helvetica;
border: 2px black solid;
width: 50%;
margin: 15%;
text-align: center;
}
pid{
color: #000;
font: arial;
}
</style>
<script type="text/javascript">
function update(){
bgcolor = document.getElementByID("bgcolor")
bgimg = document.getElementByID("bgimg")
pcolor = document.getElementByID("pcolor")
pfont = document.getElementByID("pfont")
par = document.getElementByID("par")
parea = document.getElementById('pid')

document.style.background = bgcolor;
document.style.backgroundImage = bgimg;
document.parea.style.color=pcolor;
document.parea.style.font=pfont;
document.parea.innerHTML = par;
}
</script></head>
<body>
<div id="plan">
<h1>Worldz</h1>
<form action="javascript:update()" method="POST">
<p>background color: <input type="text" id="bgcolor" size="10"></br>
background image: <input type="text" id="bgimg" size="10"></br>
paragraph color: <input type="text" id="pcolor" size="10"></br>
paragraph font:<select id ="pfont"><option id="arial">arial</option><option id="comic sans ms">comic sans ms</option>
<option id="courier">courier</option><option id="georgia">georgia</option>
<option id="helvetica">helvetica</option><option anme="impact">impact</option></select><br>
paragraph:</br>
<textarea cols = "30" rows="5" id="par">Hello World</textarea><br><br>
<button>update</button></p>
</form>
</div>
<p id="pid">Your text will appear here!</p>
</body>
</html>

Offline

 

#2 2011-04-21 13:37:27

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: JavaScript Problem.

bumpo

Offline

 

#3 2011-04-21 13:42:48

scratcher7_13
Scratcher
Registered: 2011-02-09
Posts: 1000+

Re: JavaScript Problem.

It looks fine to me.


♫ 90% of teens can't do math. If you are one of the 40% of teens who can, copy and paste this into your signature. ♫♪
http://dl.dropbox.com/u/6273449/BlockLibraryTitle.pnghttp://i.imgur.com/mr9Hf.gif

Offline

 

#4 2011-04-21 13:44:08

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: JavaScript Problem.

scratcher7_13 wrote:

It looks fine to me.

Do you know what its supposed to do? It changes the css and such of the page.

Offline

 

#5 2011-04-21 13:45:43

scratcher7_13
Scratcher
Registered: 2011-02-09
Posts: 1000+

Re: JavaScript Problem.

ProgrammingFreak wrote:

scratcher7_13 wrote:

It looks fine to me.

Do you know what its supposed to do? It changes the css and such of the page.

Yes, but I don't see a problem with the code.


♫ 90% of teens can't do math. If you are one of the 40% of teens who can, copy and paste this into your signature. ♫♪
http://dl.dropbox.com/u/6273449/BlockLibraryTitle.pnghttp://i.imgur.com/mr9Hf.gif

Offline

 

#6 2011-04-21 13:49:54

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: JavaScript Problem.

scratcher7_13 wrote:

ProgrammingFreak wrote:

scratcher7_13 wrote:

It looks fine to me.

Do you know what its supposed to do? It changes the css and such of the page.

Yes, but I don't see a problem with the code.

Could you try it out?

Offline

 

#7 2011-04-21 14:01:50

svinnik
Scratcher
Registered: 2008-08-31
Posts: 1000+

Re: JavaScript Problem.

What is it supposed to do?


http://www.harkavagrant.com/msnpaint/rabies.jpg

Offline

 

#8 2011-04-21 14:09:25

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: JavaScript Problem.

svinnik wrote:

What is it supposed to do?

Change the CSS and other stuff for the page.
http://img140.imageshack.us/img140/7413/zzworldzphoto.png

When you fill those things out and then press the button 'update', it changes it.

Last edited by ProgrammingFreak (2011-04-21 14:10:01)

Offline

 

#9 2011-04-21 15:53:12

TheSuccessor
Scratcher
Registered: 2010-04-23
Posts: 1000+

Re: JavaScript Problem.

I think the "d" should be lowercase at the end of "document.getElementById", and you need to do "document.getElementById("id").value"


/* No comment */

Offline

 

#10 2011-04-21 18:13:35

lemonpretzel
Scratcher
Registered: 2008-10-23
Posts: 100+

Re: JavaScript Problem.

TheSuccessor wrote:

I think the "d" should be lowercase at the end of "document.getElementById", and you need to do "document.getElementById("id").value"

HTML isn't case sensitive.

Offline

 

Board footer