When a specific condition is met, I want my checkboxes to automatically be checked through Javascript code in MVC.
@if (str_item != "" && str_checkroles != "" && str_item == str_checkroles) {
<script>
src = "https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" >
</script>
<script type="text/javascript">
$(function () {
$('#@(item.Text)').attr('checked', true);
$('#dummychk').prop('checked', true);
});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script>