function call not working

Discussion in 'JavaScript' started by gvm, Nov 1, 2006.

  1. #1
    function myFunction() {
    alert("yes")
    }


    <INPUT TYPE="button" onClick="javascript:myFunction()" name="joe" value="Place Order">

    When I click the form button nothing happens, no error messages either in the browser. I've placed the function in both the head and body, but still not working.
     
    gvm, Nov 1, 2006 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Take out the javascript:, it's not necessary in onX attributes.
    
    <INPUT TYPE="button" onClick="myFunction();" name="joe" value="Place Order">
    
    HTML:
     
    nico_swd, Nov 2, 2006 IP
  3. gvm

    gvm Guest

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks! It's working!
     
    gvm, Nov 2, 2006 IP
  4. sxg

    sxg Peon

    Messages:
    49
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Just wondering, how come it worked without the javascript: but didn't when you had it?

    I have used javascript: on all my onX attributes and never ran into this issue.
     
    sxg, Nov 2, 2006 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    Might depend on the browser you're using. I've never seen trouble with it either, but still, the javascript: doesn't belong there cause the browser expects a javascript in these attributes. No other code can be executed there.
     
    nico_swd, Nov 2, 2006 IP
  6. gvm

    gvm Guest

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I used caps here JavaScript: and not, javascript: and it worked this time, so not having capital letters could have been the culprit.
     
    gvm, Nov 2, 2006 IP