Set value to the TEXTFIELD using Function


var formStockIn = new Ext.FormPanel({
  xtype: "form",
  bodyPadding: 15,
  width: 700,
  closeAction: 'hide',
  modal: true,
  items: [{
                xtype: 'numberfield',
                fieldLabel: 'Total Bill',
                name: 'total_bill',
                hideTrigger: true,
                keyNavEnabled: false,
                disabled: true,
                 mouseWheelEnabled: false,
                 allowBlank: false
                 },
                 {
                  xtype: 'numberfield',                                       // or  textfiels
                  fieldLabel: 'Quantity',
                  id: 'qty',
                  hideTrigger: true,
                  keyNavEnabled: false,
                  mouseWheelEnabled: false,
                  allowBlank: false,
                  name: 'quantity',

                  listeners: {                                                      //Listner for event fire
                      'change': function(){

                        var item_qty = Ext.getCmp('qty').value;     //get inserted value of the text field

                        calculateTotal(item_qty);                           // function call

                      }
                    }
  }]
});


function calculateTotal(qtyyy){                                            // function defination

var iprice = "some data"

 var totlBill = (qtyyy * iprice);

 formStockIn.getForm().findField('total_bill').setValue(totlBill);    //set value to the Textfield

}

Where,

formStockIn = parent form Variable name;
total_bill = name of the item where u want to show the data;

Comments