PDA

View Full Version : [HELP] my checkboxgroup getting value "[object Object]"



bulongx
20 Feb 2011, 4:56 AM
My Source Code:


var pilihhari = new Ext.form.CheckboxGroup({
id:'pilihhari',
xtype: 'checkboxgroup',
fieldLabel: 'Pilih Hari',
itemCls: 'x-check-group-alt',
anchor: '60%',
columns: 7,
items: [
{boxLabel: 'Senin', name: 'Senin', value: 'Senin', checked: true},
{boxLabel: 'Selasa', name: 'Selasa', value: 'Selasa'},
{boxLabel: 'Rabu', name: 'Rabu', value: 'Rabu'},
{boxLabel: 'Kamis', name: 'Kamis', value: 'Kamis'},
{boxLabel: 'Jumat', name: 'Jumat', value: 'Jumat'},
{boxLabel: 'Sabtu', name: 'Sabtu', value: 'Sabtu'},
{boxLabel: 'Minggu', name: 'Minggu', value: 'Minggu'}
]
});
My Getting Code:

Ext.getCmp('pilihhari').getValue();My question is when it inserted on my database, why i getting value "[object Object]". There is wrong with my getting value??? plzzz help me...

drian
20 Feb 2011, 5:06 AM
Are you sure you add your checkboxgroup to a component or you render it on the page?

It should return an array of objects, each object being a checked checkbox.

bulongx
20 Feb 2011, 5:11 AM
Are you sure you add your checkboxgroup to a component or you render it on the page?

It should return an array of objects, each object being a checked checkbox.

I want to store checked object in my database, ex: i checked senin, selasa, and rabu. then in my database inserted "Senin, Selasa, Rabu" <<< like this... how i can resolve this!???

bulongx
20 Feb 2011, 5:48 PM
Are you sure you add your checkboxgroup to a component or you render it on the page?

It should return an array of objects, each object being a checked checkbox.

plzzzzzzz.... help me to make looping, plzzz gi'me ex to create that...

Condor
21 Feb 2011, 6:49 AM
1. You want 'inputValue' instead of 'value'.

2. checkboxGroup.getValue() returns an array of the selected checkboxes. You have to collect their inputValues yourself, e.g.

var value = [];
Ext.each(checkboxGroup.getValue(), function(checkbox){
value.push(checkbox.inputValue);
});
value = value.join(', ');

Durtto
20 Nov 2015, 10:55 AM
Thanks.