$(cbValue).checked returns boolean (true|false) and you compare it to
string:
if( cbState == "checked" )
simply
strState = (cbState == true) ? "checked" : "unchecked";
-wz
Try it passing cb1 into a function as cbValue and then
$(cbValue).checked...
On Apr 27, 2012 1:46 AM, "Wojtek Zadora" <woj...@studioatrium.pl
<mailto:woj...@studioatrium.pl>> wrote:
Well, I tested it and in my case having <input type="checkbox"
name="1" value="1" id="cb1">
console.log($('cb1').checked); -> returns false
console.log($('cb1').readAttribute('checked')); -> returns null
While <input type="checkbox" name="2" value="2" id="cb2"
checked="checked">
console.log($('cb2').checked); -> returns true
console.log($('cb2').readAttribute('checked')); -> returns checked
-wz
How do you get the checked state of a single checkbox?
$('cbID').checked doesn't work... also tried $F('cbID').checked
in the following function, the alert comes back with "undefined"
cdValue is the id of the checkbox...
function saveChange(cbValue)
{
var strState;
var cbState;
// get the value of the checkbox
// we do it here incase this is called
// from the onchange attached to the select
cbState = $(cbValue).checked;
alert(cbState);
if( cbState == "checked" )
strState = "checked";
else
strState = "unchecked";
}
--
You received this message because you are subscribed to the
Google Groups "Prototype & script.aculo.us
<http://script.aculo.us>" group.
To post to this group, send email to
prototype-scriptaculous@googlegroups.com
<mailto:prototype-scriptaculous@googlegroups.com>.
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com
<mailto:prototype-scriptaculous%2bunsubscr...@googlegroups.com>.
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.
--
You received this message because you are subscribed to the Google
Groups "Prototype & script.aculo.us <http://script.aculo.us>" group.
To post to this group, send email to
prototype-scriptaculous@googlegroups.com
<mailto:prototype-scriptaculous@googlegroups.com>.
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com
<mailto:prototype-scriptaculous%2bunsubscr...@googlegroups.com>.
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.
--
You received this message because you are subscribed to the Google
Groups "Prototype & script.aculo.us" group.
To post to this group, send email to
prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.
--
You received this message because you are subscribed to the Google Groups "Prototype
& script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.