jsB@nk.com


Free JavaScript Codes Download

Translate this page to English Translate this page to France Translate this page to Vietnamese

change background color using the value from combo box

Want to do something with JavaScript but it's not really good at them? Let post your request in here.

change background color using the value from combo box

Postby thebluestar on Thu Dec 24, 2009 6:29 am

Code: Select all
<html>
<head>
   <title>Nhung rac roi ko hieu</title>
   <script type="text/javascript">
         function getvalue(list)
         {
              while(list.options.length) list.options[list.selectedIndex].value=null;
              var value = list.options[list.selectedIndex].value;
              document.write(value);
              document.bgColor = value;
         }
   </script>
</head>
<body bgColor="lavender">
      Here is the list for you to Change the bgColor!
      <br/>
      <select name="list1" onchange="getvalue(this)">
            <option value="green">Green</option>
            <option value="orange">Orange</option>
            <option value="yellow">Yellow</option>
            <option value="pink">Pink</option>
      </select>
</body>
</html>

Here is my code , it works but how can I do to remain the list each time click one option . I mean when I click one option the background changes, also the combo box is remainded to try the next option!
Please help me clarify the problem. Thanks!
thebluestar
 
Posts: 1
Joined: Thu Dec 24, 2009 6:22 am


Return to Post your JavaScript request

Who is online

Users browsing this forum: No registered users and 0 guests

Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web