ahmed salah

ahmed salah

  • 1.1k
  • 547
  • 59.6k

How to pass value of retain stuff to submit function ?

Jan 21 2024 1:59 PM

I work on asp.net MVC . I can't pass value of retain stuff checkboxes to submit function Yes have id RetainStuffTrue and it is value True No have id RetainStuffFalse and it is value False if session role code not equal LM then the checkboxes retain stuff will not display so retain stuff display based on session is LM or not submit function will execute when click approve button so any one can help me how to pass value to retain stuff to submit if yes then true if No then false

@if (Session[BLL.Common.SessionKeys.RoleCode].ToString() == "LM" )
 {
 <table style="border: 1px solid black;width:100%;margin-bottom:5px;">

     <tr>
         <td style="width: 50%; font-weight: bold; padding-top: 10px;">
           
         </td>



         <td style="font-weight: bold; padding-top: 10px;">
            
     </tr>
     <tr>
         <td style="width: 50%; font-weight: bold; padding-top: 10px;">
             @Html.Label("Did you try to retain the staff?", htmlAttributes: new { @class = "control-label col-md-5" })
             <div class="col-md-7">
                 <input type="checkbox" id="RetainStuffTrue" name="RetainStuff" value="true" class="retaindtuff-checkbox" @(Model.RetainStuff == true ? "checked" : "") />
                 Yes
                 &nbsp;&nbsp;
                 <input type="checkbox" id="RetainStuffFalse" name="RetainStuff" value="false" class="retaindtuff-checkbox" @(Model.RetainStuff == false ? "checked" : "") />
                 No
             </div>
         </td>
         <td style="font-weight: bold; padding-top: 10px;">
            
         </td>
     </tr>
     <tr style="margin-bottom:5px;padding-bottom:5px;">
         

     </tr>


 </table>
 }

 <a id="approveControlsId" onclick="submit();" class="btn btn-primary" style="min-width: 100px;margin-top:5px;"><i class="glyphicon glyphicon-ok"></i> Approve </a>

<script type="text/javascript">
  function submit() {
      }
</script>
on jQuery i handle event change checkbox by jquery below



$('.retaindtuff-checkbox').on('change', function () {
    $('.retaindtuff-checkbox').not(this).prop('checked', false);
    $(this).val(this.checked);
});

 


Answers (1)