Select Checkboxlist value in mvc4
Step1 : First Create View as Folowing
@foreach (var item in @ViewBag.Hobby)
{
<input type="checkbox" name="ips" value="@item.HobbyName" />@item.HobbyName
}
Step 2 : Now you can select checkbox list value using jquery as following code
function InsertData()
{
$('input:checkbox:checked').each(function () {
v = v + $(this).attr('value') +",";
});
}
Step 3 : When you click on checkbox data can be selected using js you can pass these data by calling ajax methode
Step1 : First Create View as Folowing
@foreach (var item in @ViewBag.Hobby)
{
<input type="checkbox" name="ips" value="@item.HobbyName" />@item.HobbyName
}
Step 2 : Now you can select checkbox list value using jquery as following code
function InsertData()
{
$('input:checkbox:checked').each(function () {
v = v + $(this).attr('value') +",";
});
}
Step 3 : When you click on checkbox data can be selected using js you can pass these data by calling ajax methode
Sign up here with your email
2 comments
Write commentshi........
Replyyes, have you any prob ?
ReplyConversionConversion EmoticonEmoticon