Learning...NEED HELP!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DjShifta
    New Member
    • Jun 2007
    • 3

    Learning...NEED HELP!!

    Ok this really shouldn't be that hard...but I can not figure out whats' wrong for the life of me. I am brand new to "coding" and have thus far just built basic sites with Dreamweaver, but am going through my CIW certs, and this is an exercise i am feeling a little "dumb'' on.... any help....

    Question exactly as it's worded: Create a Web page that contains an HTML form, a list box, a button and an <img> tag. Populate the list box with at least 3 people's names and the names of three images located in the same directory; you will also need those image files accessible from the server. Use the 'onClick' event of the button object to read the attributes of the list box that store the currently selected names and associated image name. Use the JavaScript 'Load' method to script the <img> tag to load the image associated with the name.

    Now my "instructor " made a super simple example that worked, but I can not for the life of me duplicate it and actually get it to work. I am sure there are "better" ways to acheive this goal, but I am trying to do it how they want... here is the "instructor s" example he gave me


    <html>
    <head>
    <title> blah blah blah</title>

    <script type="text/javascript">
    function Load()
    {
    document.getEle mentById("Image s").src=
    document.getEle mentById("faces ").value
    }
    </script>
    </head>


    <body>

    <img id="Images" src="face1.jpg" >

    <select name="faces">
    <option value=""> Select a face
    <option value="face1.jp g">Face1
    <option value="face1.jp g">Face2
    <option value="face1.jp g">Face3
    <option value="face1.jp g">Face4
    </select>

    <input type="submit" onClick="Load() " value="selecxt" >

    </body>
    </html>

    --------------------------------------------


    Does this make sense?? I really need some advice from anyone that knows how to "complete the exercise" i am getting really frustrated....

    THANKS SO MUCH!!!!!!!!!!! !!!!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by DjShifta
    Ok this really shouldn't be that hard...but I can not figure out whats' wrong for the life of me. I am brand new to "coding" and have thus far just built basic sites with Dreamweaver, but am going through my CIW certs, and this is an exercise i am feeling a little "dumb'' on.... any help....

    Question exactly as it's worded: Create a Web page that contains an HTML form, a list box, a button and an <img> tag. Populate the list box with at least 3 people's names and the names of three images located in the same directory; you will also need those image files accessible from the server. Use the 'onClick' event of the button object to read the attributes of the list box that store the currently selected names and associated image name. Use the JavaScript 'Load' method to script the <img> tag to load the image associated with the name.

    Now my "instructor " made a super simple example that worked, but I can not for the life of me duplicate it and actually get it to work. I am sure there are "better" ways to acheive this goal, but I am trying to do it how they want... here is the "instructor s" example he gave me


    <html>
    <head>
    <title> blah blah blah</title>

    <script type="text/javascript">
    function Load()
    {
    document.getEle mentById("Image s").src=
    document.getEle mentById("faces ").value
    }
    </script>
    </head>


    <body>

    <img id="Images" src="face1.jpg" >

    <select name="faces">
    <option value=""> Select a face
    <option value="face1.jp g">Face1
    <option value="face1.jp g">Face2
    <option value="face1.jp g">Face3
    <option value="face1.jp g">Face4
    </select>

    <input type="submit" onClick="Load() " value="selecxt" >

    </body>
    </html>

    --------------------------------------------


    Does this make sense?? I really need some advice from anyone that knows how to "complete the exercise" i am getting really frustrated....

    THANKS SO MUCH!!!!!!!!!!! !!!!
    1.) Java != Javascript. Moved to Javascript forum.
    2.) When posting code, please make use of the code tags so that the code is easier to read. (It even looks prettier).
    3.) What exactly is the problem. Did you write some code yourself and get errors? Do you understand the code that was written by your teacher?

    Comment

    • DjShifta
      New Member
      • Jun 2007
      • 3

      #3
      Originally posted by r035198x
      1.) Java != Javascript. Moved to Javascript forum.
      2.) When posting code, please make use of the code tags so that the code is easier to read. (It even looks prettier).
      3.) What exactly is the problem. Did you write some code yourself and get errors? Do you understand the code that was written by your teacher?
      --------

      Hey! Okm sorry, what do you mean by make use of the Code Tags? Do you mean the # sign at the top of the message display??

      Man i feel so lame, I am JUST getting into all this and get Lingo confused....
      I got that code from the teacher, and he got the code to work on the schools computer where he had his image files stored. I retyped the Code EXACTLY, on my computer and substituted my images, and thought I matched the <select name"......name here......"> with the... document.getEle mentById("....n ame here....") which he told me must match. but it's not working.....

      The Code that i wrote in my first message is exactly what he gave me to use, but when I plug in my images (bob.jpg - joe.jpg - joh.jpg and so on...) i can' not get it to work.

      Any help is greatly appreciated as I am litteraly like 4weeks into my CIW training and have so much info thrown at me it is difficult to remember all the different code and lingo terms right now!!!! I am really trying to grasp this example, but the instructors really aren't that great....

      THANKS!!

      Comment

      • ronnil
        Recognized Expert New Member
        • Jun 2007
        • 134

        #4
        Hi there

        When working with document.getEle mentById you must give the HTML element who's value you wish to retrieve an id. (name and id are two different things ;) )

        so instead of
        Code:
        <select name="faces">
        you will have to use
        Code:
        <select name="faces" id="faces">
        this should get it to work properly

        Comment

        • DjShifta
          New Member
          • Jun 2007
          • 3

          #5
          Originally posted by ronnil
          Hi there

          When working with document.getEle mentById you must give the HTML element who's value you wish to retrieve an id. (name and id are two different things ;) )

          so instead of
          Code:
          <select name="faces">
          you will have to use
          Code:
          <select name="faces" id="faces">
          this should get it to work properly


          Thank you! I will try this when I get home from work! :)

          Thanks for the help!!!!

          Comment

          Working...