Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

108
Views
how to make a pull down menu which chnages background color

i've tried to make a pulldown menu which changes the page background color, but it doesnt work. any suggestions?

<body>

<select name="colors" onechange="changeColors(this)">
    <option value="blue">Blue</option>
    <option value="#868B8E">Grey</option>
    <option value="#FFC55C">Orange</option>
</select>

<script src="images8.js"></script>
</body>

the js

function changeColor(event)
{
    var color = event.value;
    document.getElementsByTagName('BODY')[0].style.backgroundColor=color;
    
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Your code runs fine when the typos are corrected:

onechange -> onchange

changeColors(this) -> changeColor(this)

See working snippet

You might want to add an onload event to begin with the default colour.

function changeColor(event)
{
    var color = event.value;
    document.getElementsByTagName('BODY')[0].style.backgroundColor=color;
    
}
<select name="colors" onchange="changeColor(this)">
    <option value="blue">Blue</option>
    <option value="#868B8E">Grey</option>
    <option value="#FFC55C">Orange</option>
</select>

about 4 years ago · Juan Pablo Isaza Report

0

You have few typos in your code:

Function call is "changeColors" but the function name is "changeColor".

Also the correct event name is "onchange" not "onechange"

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!