Announcement

Collapse
No announcement yet.

Java script help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java script help

    A mate of mine has to do this for college, this is what he has, but it only goes blue. Anyone know what's up?

    Code:
    <HTML>
    <HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    function ChangeScreenColour()
    {
     var choice = document.FormsExample.PickColour.selectedindex
     if (choice=='0') document.bgColor='red';
     else if (choice=='1')   document.bgColor='green';
     else document.bgColor='blue';
    }
    </SCRIPT>
    <TITLE>  Forms and web page links  </TITLE>
    </HEAD>
    <BODY>
    <FORM NAME ="FormsExample">
    <B>choose a colour from the list and observe that the screen changes to this colour when you click the 'ColourChange' button
    </b><br><br>
    <SELECT NAME = "PickColour" size = 3>
    <OPTION> Red
    <OPTION> Green
    <OPTION> Blue
    </SELECT>
    <br><br><br>
    <INPUT TYPE = "button" NAME = "ColourChange"
    onClick = ChangeScreenColour()
    VALUE = "Change Colour" >
    <br><br><br>
    Now lets see whats on the BBC television tonight by loading the BBC Web pages
    <a href="[url="http://www.bbc.co.uk/"]http://www.bbc.co.uk/[/url]"> BBC TV </a>
    </FORM>
    </BODY>
    </HTML>

  • #2
    change the line to:
    Code:
    var choice = document.FormsExample.PickColour.selectedIndex
    the capital 'I' in selectedIndex is important

    Comment


    • #3
      he thanks a millions thank you's

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...
      X