Change background : JavaScript DHTML examples (example source code) » Form Control » Option Select ComboBox

JavaScript DHTML
C++
Java Products
Java Articles
JavaScript DHTML Home  »   Form Control   » [  Option Select ComboBox  ]   
 



Change background

Please note that some example is only working under IE or Firefox.

/*
JavaScript Application Cookbook
By Jerry Bradenbaugh

Publisher: O'Reilly 
Series: Cookbooks
ISBN: 1-56592-577-7
*/ 
<HTML>
<HEAD>
  <TITLE>Change background</TITLE>
</HEAD>
<SCRIPT>
<!--

function bgChange(selObj) {
  newColor = selObj.options[selObj.selectedIndex].text;
  document.bgColor = newColor;
  selObj.selectedIndex = -1;
  }

//-->
</SCRIPT>
<BODY STYLE="font-family:Arial">
<B>Changing Background Colors</B>
<BR>
 <FORM>
   <SELECT SIZE="8" onChange="bgChange(this);">
   <OPTION>Red
   <OPTION>Orange
   <OPTION>Yellow
   <OPTION>Green
   <OPTION>Blue
   <OPTION>Indigo
   <OPTION>Violet
   <OPTION>White
   </SELECT>
 </FORM>
</BODY>
</HTML>
Related examples in the same category
1.  Option selected index
2.  Auto Linked Option Listbox without button
3.  Changing Select Element Content (two Combobox)
4.  Drop-down Redirect - No Submit button
5.  Drop-down Redirect - Submit
6.  Dropdown list (combobox) in a form
7.  dropdown list (combobox) in form 2
8.  Disable or enable an option
9.  Disable and enable a dropdown list (combobox)
10.  Return the name of the form that contains dropdown list (combobox)
11.  Number of options in the dropdown list(Combobox)
12.  Change the size of a dropdown list (ComboBox)
13.  Select multiple options in a dropdown list (option)
14.  Return the selected option as text in option
15.  Return the selected option as a number
16.  Change the option text
17.  Remove an option from a dropdown list (combobox)
18.  Methods and Properties of the Select Object
19.  Properties of the Option Object
20.   Using the Location object to change another frame's URL
21.  Using a Summary Form to Support Local Processing
22.  Navigating with a SELECT Object
23.  Using the selectedIndex Property
24.   Modifying OPTGROUP Element Labels
25.  Using the options[index].text Property
26.   Using the options[index].value Property
27.  Triggering a Color Change from a Pop-Up Menu
28.  Modifying SELECT Options
29.  Modifying SELECT Options (IE4+)
30.  Modifying SELECT Options (NN6+)
31.  Selecting an Option Using JavaScript
32.  Linked ComboBox (option) Country =- province
33.  ComboBox set value to TextField
34.  Menu(Option) Generator
35.  URL Option ComboBox
36.  Show Selected Option items








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.