SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2007
    Location
    Regina, SK, Canada
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    OOP broken in IE6.. What am I doing wrong?

    The code below works in FF but I get an error in IE6 saying "User is undefined".
    This happens when I call onclick="User.init();" on an input button
    Any ideas?

    <head>
    <script type="text/javascript">
    var User = {

    // globals...
    firstnameFieldId: 'firstname', // firstname
    lastnameFieldId: 'lastname', // lastname
    requiredUsernameKey: 0, // array key in requiredFields
    requiredPasswordKey: 1, // array key in requiredFields
    requiredConfPasswordKey: 2, // array key in requiredFields
    submitBtnId: "submitbtn", // the id of the submit button


    init: function(){

    User.resetAll();

    },

    resetAll: function(){

    alert('has been reset!');

    }

    }
    </script>
    </head>

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    This test seems to be working fine. Is it perhaps some other conflict?

    Code html4strict:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>Test</title>
    <script type="text/javascript">
    var User = {
    	// globals...
    	firstnameFieldId: 'firstname', // firstname
    	lastnameFieldId: 'lastname', // lastname
    	requiredUsernameKey: 0, // array key in requiredFields
    	requiredPasswordKey: 1, // array key in requiredFields
    	requiredConfPasswordKey: 2, // array key in requiredFields
    	submitBtnId: "submitbtn", // the id of the submit button
    	init: function(){
    		User.resetAll();
    	},
    	resetAll: function(){
    		alert('has been reset!');
    	}
    }
    </script>
    </head>
    <body>
    <input type="button" value="Reset User" onclick="User.init()">
    </body>
    </html>
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •