here i am writing the code like this but unable to get selected checkbox value.if anyone knows how to get selected checkbox value.
$(function () {
$('#chkType').click(function () {
var checked = $("#chkType").is(':checked');
alert(checked); return false;
});
});
});
});


Joginder BangerRank #360 · 7K reputationPosted Nov 14, 2014, 12:04 AM EST
Joginder BangerRank #360 · 7K reputationPosted Nov 14, 2014, 12:28 AM EST
function myfun() {
var temp =document.getElementById("CheckBox1").checked;
alert(temp);
}
jquery used
var temp= $("#CheckBox1").is(':checked');
alert(temp);
it's working on my machine.
Sarath KumarRank #3,637 · 402 reputationPosted Nov 14, 2014, 12:33 AM EST
Joginder BangerRank #360 · 7K reputationPosted Nov 14, 2014, 12:35 AM EST
Sarath KumarRank #3,637 · 402 reputationPosted Nov 14, 2014, 12:49 AM EST
for example,bus type Ac,NonAc is there.if i check Ac i need to print "Ac".got it...
Jitendra KumarRank #760 · 3K reputationPosted Nov 14, 2014, 1:03 AM EST
$("#CheckBus").on("click",function () {
$("#parentId").find('input[type="checkbox"]').each(function(){
if ($(this).prop('checked')==true){
alert($(this).prop('id') +" is checked")
}
else
{
alert("Please check checkbox")
}
});
});
Or check this link:
http://jsfiddle.net/ah1qq654/1/
Joginder BangerRank #360 · 7K reputationPosted Nov 14, 2014, 1:03 AM EST
$('#CheckBox1').click(function (e) {
if( $("#CheckBox1").is(':checked'))
alert($("#CheckBox1").next('label').text());
else
return false;
});
});
alert the message acbus.