I work on asp.net mvc I face issue i can't store value of health status on hidden field using jQuery then pass hidden field value after get value to approve () function when click agree button click on hidden field i will assign value true when checkbox Yes checked and assign value false when check box No checked then after hidden field get value true or false i will pass it to approve function java script when click button agree i'm not use hidden field before so can you help me please
<td style="width: 50%; font-weight: bold; padding-top: 10px;">
@Html.Label("HealthStatus?", htmlAttributes: new { @class = "control-label col-md-5" })
<div class="col-md-7">
<input type="checkbox" id="HealthStatusTrue" name="HealthStatus" value="true" class="healthstatus-checkbox" @(Model.HealthStatus == true ? "checked" : "") />
Yes
<input type="checkbox" id="HealthStatusFalse" name="HealthStatus" value="false" class="healthstatus-checkbox" @(Model.HealthStatus == false ? "checked" : "") />
No
</div>
</td>
<a id="approveControlsId" onclick="approve();" class="btn btn-primary" style="min-width: 100px;margin-top:5px;"><i class="glyphicon glyphicon-ok"></i> agree </a>
ASP.NET (C#)
Copy
on csharp property HealthStatus is boolean as below
public class HealthStatusData
{
public bool? HealthStatus {get;set;}
}
C#
Copy
so how to create hidden field then assign value of Healthstatus to hidden field using jQuery
$('.healthstatus-checkbox').on('change', function () {
// how to assign value to hidden field
});
JavaScript
Copy
then after that pass to approve function java script
<script type="text/javascript">
function approve() {
var HealthStatusData = new Object();
HealthStatusData.HealthStatus = ???????????????
// how to get hidden field value here
}
</script>
JavaScript??