I have 3 checkboxes but they are showing as undefined in an alert box. Is there a trick to getting them to show a value? I tried putting a value of 1 in the input tag but it still reports as undefined.
Ok, thanks.. Here is some code.
else if (item.field == "admCustRptDly" && item.value == "1")
{
$('#admCustRptDly').attr('checked', true);
}
else if (item.field == "admCustRptSumm" && item.value == "1")
{
$('#admCustRptSumm').attr('checked', true);
}
else if (item.field == "admCustRptDtl" && item.value == "1")
{
$('#admCustRptDtl').attr('checked', true);
}
<input type="checkbox" id="admCustRptDly" name="admCustRptDly" class="admChkbx">
<input type="checkbox" id="admCustRptSumm" name="admCustRptSumm" class="admChkbx">
<input type="checkbox" id="admCustRptDtl" name="admCustRptDtl" class="admChkbx">
your jquery is off, this doesn't quite give the response you'd expect, rather to find if a check box is checked:
var checked = $("#admCustRptDtl:checked").val();
Also, the checked attribute will never equal true, the html is actually checked="checked"
else if (item.field == "admCustRptDly" && item.value == "1")
I don't understand what are you trying to do here? I'm guessing you are trying to verify the value of "admCustRptDply" checkbox. Maybe post also the code before this. You can get the value like this:
var val = $("#admCustRptDly").val()
But in your HTML the checkboxes don't have a value attribute.
You can get the checked property of a checkbox like this:
var checked = $("#admCustRptDly").attr("checked")
And you can set it like this:
$("#admCustRptDly").attr("checked","checked")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With