onChange doesn't (always) work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rienc
    New Member
    • May 2010
    • 3

    onChange doesn't (always) work

    this piece of code works, the function daysCheck() can be found in a seperate js file included in the head.
    Code:
    <select id="month" name="month" class="dateselect" onChange="daysCheck()">
    	<option ...
    	...</option>
    </select>
    
    <select id="year" name="year" class="dateselector" onChange="daysCheck()">
    	<option ...
    	...</option>
    </select>
    a bit further in the file this piece of code can be found.
    Code:
    <select id="soort" name="soort" onChange="soort()">
    	<option disabled="disabled">...</option>
    	<option ...
    	...</option>
    </select>
    And this doesn't work, the function soort() can be found in the same file as daysCheck().
    soort() looks like: (just for testing)
    Code:
    function soort()
    {
    	alert('hello');
    }
    on the other hand if I do this it does give the alert.
    Code:
    <select id="soort" name="soort" onChange="alert('hello')">
    	<option disabled="disabled">...</option>
    	<option ...
    	 ...</option>
    </select>
    note that the select elements can be found in the same (and only) form on the page. And that the very first piece of code is generated with php. I tried different browsers (IE, FF, chrome, safari) and none of them works.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    in the second <select>, are all <option>s disabled?

    Comment

    • rienc
      New Member
      • May 2010
      • 3

      #3
      Originally posted by Dormilich
      in the second <select>, are all <option>s disabled?
      no, just the first one, there are 6 other <option>s.

      Comment

      • rienc
        New Member
        • May 2010
        • 3

        #4
        ok, wierd...
        I have been looking for the source of this problem for a day or so, if I change the name of the function soort() to soortCheck() there seems to be no problem. Does anyone know what may cause this?

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Because you have an ID and name of the same name, so what you've posted is the solution to your problem.

          Comment

          Working...