PDA

View Full Version : [SOLVED] How do I access true/false value of Ext.get.('checkbox-toggle').dom.checked?



kevin-berry
12 Jul 2010, 1:43 PM
Hi,

I have a checkbox-toggle. When validating the form, I determine if the checkbox is on or off:

var parent_sub_id_isChecked = Ext.get('parent_sub_id_checkbox_toggle').dom.checked;

This, according to my output, will return 'true' or 'false'

The problem is that when I do :


if(parent_sub_id_isChecked == "true")
alert("returned true");
else
alert("returned false");the condition always fails - as if 'true' or 'false' is encoded differently within the variable itself, despite the output being what I want it to be.

Can anyone offer some insight?

Thanks!

Kevin

Condor
12 Jul 2010, 11:16 PM
It doesn't return 'true' or 'false' (string). It returns true or false (boolean).

So you can simply use:

if(parent_sub_id_isChecked)
alert("returned true");
else
alert("returned false");

kevin-berry
13 Jul 2010, 9:15 AM
Hey Condor, thanks! I really thought I'd already tried that. Apparently not... it worked like a charm. Thanks for the clarification of the boolean value of that. I should've realized. One of those "d'oh!" moments. *sigh*

Kevin