#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    171
    Rep Power
    11

    Unhappy Function Problem in IE8


    I have a simple test script with a JavaScript function which does not execute in IE8. When the checkbox is checked or unchecked, it should open an alert window.

    It works fine in IE10, Chrome and Firefox.

    There are no errors showing in the IE webmaster debug tool. Can anyone see what the problem is here?


    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Testing JS</title>
    
    
    </head>
    <body>
    <?PHP $p1_track = 'front'; ?>
    <form action="" method="post" id="course">
    
              <table width="600" border="1" cellpadding="3" cellspacing="0" style=" margin:40px auto;">
                <tbody>
                  <tr>
                    <td width="50%">
                        <div class="checkboxes" style="width:120px; margin:0px; border:0px solid red; font-size:80%; font-style:italic; font-weight:bold;">
                        <label for="play_card"><input id="play_card" onChange="add_blind(this,'<?PHP echo $p1_track;?>')" name="play_card" type="checkbox" value="1" <?PHP echo $checked; ?>>Play The Card</label>
                        </div>
                    </td>
                  </tr>
                </tbody>
              </table>
              
    </form>
    
     
    <script language="javascript" type="text/javascript">
    <!--
    
    // play the blind - no opponent
    function add_blind(ckbox,track){
    // if un-checked
    if(ckbox.checked == true){alert('Box is checked');}
    // if un-checked
    if(ckbox.checked == false){alert('Box is unchecked');}
     }
    
    //-->
    </script>
    
    
    </body>
    </html>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    171
    Rep Power
    11
    I changed the onChange event to onClick and now everything works in all browsers including IE8. In my actual application, that fix is OK.

    I would still like to hear comments on why the onChange event won't execute the js function in IE8 if anyone knows. Everything I have read indicates that it should.
  4. #3
  5. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,009
    Rep Power
    2791
    The reason is because Microsoft do not hire competent coders, who find it very difficult to stick to standards or even simple logic.

    There are various answers to the problem.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    171
    Rep Power
    11
    Originally Posted by Winters
    The reason is because Microsoft do not hire competent coders, who find it very difficult to stick to standards or even simple logic.

    There are various answers to the problem.

    Thanks for the info Winters. MS needs to update their browsers rather than requiring a new version.

IMN logo majestic logo threadwatch logo seochat tools logo