onChange error!

Discussion in 'JavaScript' started by Pudge1, Aug 7, 2009.

  1. #1
    Pudge1, Aug 7, 2009 IP
  2. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #2
    Bump can someone please help me I cannot find the error.
     
    Pudge1, Aug 9, 2009 IP
  3. Unni krishnan

    Unni krishnan Peon

    Messages:
    237
    Likes Received:
    9
    Best Answers:
    2
    Trophy Points:
    0
    #3
    Its the problem with function names.
    You are using spaces inside function name,
    which are not allowed. Like,
    Give Names without spaces like this,

     
    Unni krishnan, Aug 10, 2009 IP
  4. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #4
    Trying it out we'll see what happens.
     
    Pudge1, Aug 10, 2009 IP
  5. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #5
    EDIT: Still does not work...
     
    Pudge1, Aug 10, 2009 IP
  6. sebau

    sebau Peon

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Maybe in this funtcions use .src no setAttribute.
    Try paste this in any function and call this function.
    example:
    if it works in next step try with Your images ;)
     
    sebau, Aug 10, 2009 IP
  7. adstiger

    adstiger Peon

    Messages:
    409
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    onChange is tricky, I suggest you to please try only onChange function in a seperate html file, if it works, then implement there.
     
    adstiger, Aug 10, 2009 IP
  8. NoamBarz

    NoamBarz Active Member

    Messages:
    242
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #8
    You need to set the onchange to the <select> element and not the options.
     
    NoamBarz, Aug 11, 2009 IP
  9. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #9
    Then how do I make something happen when they choose different options.
     
    Pudge1, Aug 11, 2009 IP
  10. NoamBarz

    NoamBarz Active Member

    Messages:
    242
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #10
    each option has a value. use: <select name='sss' onchange='javascript:doSomething(this.value);'>
    the value passed to the function changes according to the option selected. You can handle each value differently.
     
    NoamBarz, Aug 12, 2009 IP
  11. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #11
    Can you show me an example
     
    Pudge1, Aug 12, 2009 IP
  12. NoamBarz

    NoamBarz Active Member

    Messages:
    242
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #12
    <script language='javascript'>

    function HandleOptions(v){
    if(v==0) alert("example 1");
    else if(v==1) alert("example 2");
    else alert(v);
    }

    </script>


    <select name='test' onchange='javascript:HandleOptions(this.value);'>
    <option value='0'> option 1</option>
    <option value='1'> option 2 </option>
    <option value='2'> option 3 </option>
    </select>


    I hope this helps
     
    Last edited: Aug 12, 2009
    NoamBarz, Aug 12, 2009 IP
  13. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #13
    I am not too good with JavaScript so kind of but not really :(
     
    Pudge1, Aug 13, 2009 IP
  14. adstiger

    adstiger Peon

    Messages:
    409
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Have you tried onChange() in seperate html file?
     
    adstiger, Sep 9, 2009 IP