Results 1 to 1 of 1

Thread: SelectedIndex

  1. #1
    Join Date
    Apr 2013


    I am going around in circles. Using JS to allow combo box to decide the background colour, (one of three) of a square. This is my .js file:
    The css file creates the box size and colours. I think the problem arethe lines following function nextColour.

    Many, many thanks to everyone who responds.

    window.onload = initForm;

    function initForm(){
    document.selectStatus.newColour.getElementById("ne wColour").selectedIndex = 0;
    document.selectStatus.newColour.getElementById("ne wColour").onchange = nextColour;

    function nextColour(){
    case selectedIndex=1; = "red";

    This is my html:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">

    <title>Welcome to jQuery #3!</title>
    <link rel="stylesheet" href="color.css">
    <script src=""></script>
    <script src="color.js"></script>


    <table width="610px">
    <tr><td>Overall Status</td>
    <form name="selectStatus">
    <select name="newColour">
    <option value="space"></option>
    <option value="red" id="red">Red</option>
    <option value="amber">Amber</option>
    <option value="green">Green</option>
    <td div id="colorMe" class="box"></div></td>

    Last edited by Puddleduck; 04-21-13 at 10:08. Reason: space shown on newColour

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts