PDA

View Full Version : Options to do this...???



wolverine4277
6 Jul 2007, 5:44 AM
This is the situation, i have one form with many fields in it.
One of those fields is:


var clientAccount = new Ext.form.NumberField(
{
allowBlank: false,
allowNegative: false,
fieldLabel: 'clientAccount',
id: 'clientAccount',
maxLength: 5,
minLength: 5,
width: 45
}
);

and when the user type a valid account and press the Enter key the function getAccountInformation(account) is called:


clientAccount.on(
'specialKey',
function(field, event) {

if (event.getKey() == event.ENTER) {
if (field.isValid()) {
getAccountInformation(field.getValue());
}
}
}
);



function getAccountInformation(accountValue) {

var store = new Ext.data.Store(
{
proxy: new Ext.data.HttpProxy(
{
url: '../../../php/accountInformation.php'
}
),
reader: new Ext.data.XmlReader(
{
record: 'account'
},
['name', 'address']
)
}
);
store.load(
{
callback: function(record, options, success) {

if (success) {
if (this.getTotalCount() == 1) {
Ext.getDom('name').value = registro[0].data.name;
Ext.getDom('address').value = record[0].data.address;
} else {
Ext.getDom('name').value = '';
Ext.getDom('address').value = ''; }
}
} else {
// Error management
}
},
params:
{
account: accountValue
}
}
);
}
}


Certain information of the account is not for show in the form (for example, address), but this address value must be record on a table on submit.
Actually i have a hidden field associated with this value and use this for the submit. There is another way to do this?
Another question, now i setting the values manually from the store:


Ext.getDom('name').value = registro[0].data.name;
Ext.getDom('address').value = record[0].data.address;

but i think that must be a way like the one used with combos or form load but i can't figure out how do this... all orientation will be apreciated... thanks...