0

Hey, i cant seem to get this to work, im a little confused on how im supposed to pass the colour paramaters:

function colourGreen(red, green, blue)
 {
 document.getElementById("button1").style.backgroundColor = 'rgb(red,green,blue)';
 }

............. .............

<input type="button" id = "button2" value="Price up" onclick = 'colourGreen(0,255,0)'>
asked Jul 1, 2010 at 20:50
0

3 Answers 3

3

I'm guessing this should do the trick

function colourGreen(red, green, blue)
 {
 document.getElementById("button1").style.backgroundColor = 'rgb('+red+','+green+','+blue')';
 }
answered Jul 1, 2010 at 20:52
Sign up to request clarification or add additional context in comments.

Comments

1
...'rgb('+red+','+green+','+blue+')';
answered Jul 1, 2010 at 20:51

Comments

1
.style.backgroundColor = 'rgb(' + red +', ' + green + ', ' + blue ')';
answered Jul 1, 2010 at 20:52

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.