pmac38CDS
asked on
Get value of a html checkbox in the onchange event
I have an html checkbox called isAOI. I want to be able to get the value in the onchange event. How do I go about doing so ?
Thanks,
Aditya
Thanks,
Aditya
If you wanted a function to get this then you could do:
<script>
function cbCheck(oFld)
{
alert(oFld.checked);
}
</script>
Then in your HTML:
<input type="checkbox" name="isAOI" value="" id="isAOI" onchange="cbCheck(this);">
<script>
function cbCheck(oFld)
{
alert(oFld.checked);
}
</script>
Then in your HTML:
<input type="checkbox" name="isAOI" value="" id="isAOI" onchange="cbCheck(this);">
jQuery test page : http://jsfiddle.net/F27HB/
$(document).ready(function() {
$(":checkbox[name='isAOI']").change(function() {
var checkbox_Value = $(this).val();
alert( checkbox_Value );
})
});
ASKER
Here is what I have
var input = '<input type="text" name="special" value="' + text + '" size="' +size +'" onchange="UpdateSFValue(' + intId + ',this.value)">';
No matter if the checkbox is checked or unchecked it passes the default value to the UpdateSFValue method.
Aditya
var input = '<input type="text" name="special" value="' + text + '" size="' +size +'" onchange="UpdateSFValue(' + intId + ',this.value)">';
No matter if the checkbox is checked or unchecked it passes the default value to the UpdateSFValue method.
Aditya
What are you trying to do here? The input you have shown is a text box. Can you supply the code for UpdateSFValue()?
ASKER
Sorry about that
var input = '<input id="isAOI" type="checkbox" size="' + size + '" onchange="UpdateSFValue(' + intId +' ,this.value)">Is AOI?';
The UpdateSFValue method is something that is pretty specific to our system.
Aditya
var input = '<input id="isAOI" type="checkbox" size="' + size + '" onchange="UpdateSFValue(' + intId +' ,this.value)">Is AOI?';
The UpdateSFValue method is something that is pretty specific to our system.
Aditya
Where do you want to pass the true/false result of that function?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You should then assing the input labeled box the returned value, I guess.
ASKER
This solution worked.
alert(bChecked);