marquis
December 19, 2011, 11:14am
#1
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’);
marquis
December 19, 2011, 12:59pm
#3
thanks chouette. getCheckedValue works for radio button.
any ideas for checkboxs?
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
Andrei
August 15, 2012, 2:00pm
#7
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.