View Full Version : Radio Help Needed

7 Oct 2010, 5:44 AM
I am trying to access the value of a selected radio, it is not in a radio group, it is just a couple of radios with the same name. However, every time i try to access the value i keep coming up with checked.

7 Oct 2010, 6:18 AM
You need to call getValue() on the specific Ext.form.Radio that you want to know the value of.

I created an example for you showing different ways of fetching form values.

Ext.onReady(function() {
var form = new Ext.form.FormPanel({
renderTo: document.body,
defaults: {
xtype: 'radio',
name: 'test' //Same name for all
items: [
{ fieldLabel: 'rad 1', checked: true }, //Rad 1 is checked
{ fieldLabel: 'rad 2' },
{ fieldLabel: 'rad 3' }
listeners: {
'afterrender': function() {
var it = this.items.itemAt.createDelegate(this.items),
for (i = 0; i < this.items.getCount(); i++)
console.log('rad ' + (i + 1) , it(i).getValue());

//Returns values as they would be normally submitted with an html form.
//This will always return 'on' if any of the radio with the same name is checked.
console.log('getValues()', form.getForm().getValues());

//Retriving values using getValue() on each fields.
console.log('getFieldValues()', form.getForm().getFieldValues());

7 Oct 2010, 6:23 AM
Thanks! I think i have the right radio selected. I am using the change event as follows.

MyForm = this;
Ext.iterate(obj.data, function(val, index){
boxLabel: val.invPO,
columnWidth: 0.5,
itemId: val.invPO,
inputValue: val.invPO,
check: function(thisCheckBox,newChecked){