Results 1 to 4 of 4

Thread: Help me!

  1. #1
    Join Date
    May 2012

    Help me!

    Hi im a beginner to java script and was just wondering if someone could have a look to see where im going wrong.

    Basically what i am trying to do is make it so a image changes when i select a different radio button, for example when i click green the shirt will go from the default color and change to green.

    Here is my script

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <link href="../Documents/College/Web Design Assignment/MovieProps/images/styles.css" rel="stylesheet" type="text/css" />

    <script type = text "text/javascript">

    function displayClothesPics(box){

    var ClothesPics = new Array(3)
    ClothesPics[1]="../Documents/College/Web Design Assignment/MovieProps/images/cat1prod1thumb.jpg"
    ClothesPics[2]="../Documents/College/Web Design Assignment/MovieProps/images/editedredcat1prod1thumb.jpg";
    ClothesPics[3]="../Documents/College/Web Design Assignment/MovieProps/images/editedbrowncat1prod1thumb.jpg";
    document.getElementById('MainImage').src = ClothesPics[parseInt(box.value)];


    <form name="ColourSelections">

    <h2>Colour Selection</h2>
    <input type="radio" name="Colour" value="1" onclick="UpdateImage(this.form);">Blue

    <input type="radio" name="Colour" value="2" onclick="UpdateImage(this.form);">Red

    <input type="radio" name="Colour" value="3" onclick="UpdateImage(this.form);">Brown


    <img src="../Documents/College/Web Design Assignment/MovieProps/images/editedpurplecat1prod1thumb.jpg" name="MainImage" id="MainImage" />



    Help would be appreciated
    thank you

  2. #2
    Join Date
    Nov 2007
    1: this
    <script type = text "text/javascript">
    should be
    <script type = "text/javascript">

    2: your radio buttons call "UpdateImage" but your function is named "displayClothesPics"

    3: you are passing the form into the function, but then asking for the value of the form... forms don't have values, elements *inside of* forms have values. Change to just passing "this"

    4: your HTML is malformed (though not critical to your question) - your opening and closing of TDs and TRs don't match up.

    If this weren't a homework assignment, I'd post code that works... but the above tells you everything that is wrong with the functionality you requested aid with.

  3. #3
    Join Date
    May 2006
    Somewhere behind your screen
    lol )) AndrewHardy21, you should hide your images src from nap0leon to get the working code!
    signature under construction

  4. #4
    Join Date
    Feb 2012
    Bokaro Steel City (Jharkhand), India!


    Quote Originally Posted by padonak View Post
    lol )) andrewhardy21, you should hide your images src from nap0leon to get the working code!
    "It will never rain roses: when we want to have more roses, we must plant more roses." - George Eliot

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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