PDA

View Full Version : how to send a value for a checkbox when it is unchecked



flamant
21 Oct 2010, 5:46 AM
Hi,
I have a formpanel with checkboxes. When I submit the form if a checkbox is not checked no value is posted. Do you know a way to post the value (and what value) in both cases, that is when the checkbox is checked or not ?

Thank you in advance for your answers.

designieure
21 Oct 2010, 5:57 AM
Hi,

depends on what youre going to do:-)
a typical example is function on check.

you can also but the function on your form e.g. myform.on('submit', function() {

(...) youractioncode(...)

});

Examples:

myform.on


mycheck.on('check', function()
{
var theval = mycheck.getValue();

//unchecked
if (theval == true)
{
document.getElementById('myhiddenfield').value='Y';
}

//unchecked
if (theval == false)
{

document.getElementById('myhiddenfield').value='N';
}



});
Cheers

Michael

flamant
21 Oct 2010, 6:05 AM
You mean to use another field than the checkField and post this another field ?

Foster
21 Oct 2010, 6:07 AM
I found this old thread:
http://www.sencha.com/forum/showthread.php?4580-Assign-quot-Value-quot-to-Checkbox/page3

It seems there is no built-in way to do it, but the workaround is using a hidden field such as in this post:
http://www.openboxdev.com/?p=213

designieure
21 Oct 2010, 6:08 AM
Yes however this is just an example.

Sure...You can fill other fields depending from choice. OR you can set different functions/actions depending on truew or false...

flamant
21 Oct 2010, 6:11 AM
Thank you for your answers