PDA

View Full Version : please help on javascript syntax problem



hygo
21 Jun 2007, 10:21 AM
Because I want to build a form and post its data to PHP script, so i used an example from tutorial and modified the 'addButton' function by myself. Unfortunatly, this doesn't work. when i click the button it returns an error


msg has no properties
msg.load({


Ext.onReady(function(){

Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';

var form_register = new Ext.form.Form({
labelAlign: 'left',
labelWidth: 175,
buttonAlign: 'right'
});

var register_username = new Ext.form.TextField({
fieldLabel: 'Username',
name: 'username',
width:190
});

var register_password = new Ext.form.TextField({
fieldLabel: 'Password',
name: 'password',
width:190
});

var register_email = new Ext.form.TextField({
fieldLabel: 'Email',
name: 'email',
width:190
});

form_register.fieldset(
{legend:'Registration'},
register_username,
register_password,
register_email
);

form_register.addButton('Register', function(){
var msg = Ext.get("msg");
msg.load({
url: ["http://localhost/scuttle/ajax_response.php"],
params:{username: Ext.get('username').dom.value, password: Ext.get('password').dom.value, email: Ext.get('email').dom.value},
text: "Updating..."
});
msg.show();
}, form_register);

form_register.render('register-form');

});


Any help on that? Thanks!

brian.moeskau
21 Jun 2007, 10:59 AM
Probably means that Ext.get('msg') is not returning a valid Element. You sure that there's an element on the page with id 'msg'? Try putting a breakpoint on the msg.load line and see what msg looks like. It's probably undefined.

efege
21 Jun 2007, 11:06 AM
url: ["http://localhost/scuttle/ajax_response.php"],



Note that you are passing an Array as the value for url; it should be a String or Function, see http://extjs.com/deploy/ext/docs/output/Ext.Element.html#load

hygo
21 Jun 2007, 11:23 AM
yes, its undefined. i put a <div id="msg"> and then it works.

thanks