how to get checkbox and radio value on buttonclick event?

Hi,

I have several checkboxs and radio buttons and a “apply” button on the form.

how to get checkbox and radio value when i click “apply” button?

I couldn’t find any example either on website or forum.

I tried getItemValue, getSelect, etc. none of them worked.

can somebody help?

many thanks.

This works
var x = myForm.getCheckedValue(‘radio_name’);

thanks chouette. getCheckedValue works for radio button.

any ideas for checkboxs?

I have the same problem.

Try this (it works for me)
myForm.forEachItem(function(id){
if(myForm.getItemType(id)==‘checkbox’){
if(myForm.isItemChecked(id)){
alert(‘this ’ + id + ’ is checked’);
} else {
alert(‘this ’ + id + ’ is not checked’);
}
}
});

myForm.isItemChecked(“mycheckboxname”)

is more or less the same as the previous answer, but more succinct

hi all

getItemValue will return value if chechbox checked, if value not set - to get 1/0 (depending on check-state - here fix viewtopic.php?f=17&t=25322)

getItemValue for radio also should return value of checked item (make sure you added it in init)

also there is getFormData(), will return all name-value pairs.