Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>here's a quick solution off the top of my head (table shortened due to my laziness):</p> <p><strong>HTML/RAZOR</strong>:</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;th&gt;ApplicantName&lt;/th&gt; &lt;th&gt;Confirm&lt;/th&gt; &lt;th&gt;&lt;/th&gt; &lt;/tr&gt; @foreach (var item in Model.PendingSickLeave) // this is a List&lt;&gt; { &lt;tr&gt; &lt;td&gt;@item.UserFullName&lt;/td&gt; &lt;td&gt;@Html.CheckBoxFor(m =&gt; item.SickSheet, new { @id = "chk" + @item.ApplicationID })&lt;/td&gt; &lt;td&gt;@Html.ActionLink("Process", "ProcessSickLeave", new { id = item.ApplicationID }, new { @class="submit", @data_val = item.ApplicationID })&lt;/td&gt; &lt;/tr&gt; } &lt;/table&gt; </code></pre> <p><strong>JQUERY SCRIPT</strong>:</p> <pre><code>&lt;script&gt; $(function () { // captures click event. appends the sicksheet querystring on the url. $('a.submit').click(function (e) { e.preventDefault(); var id = $(this).attr('data-val'); var chk = $('#chk' + id); if ($(chk).is(':checked')) $(this).attr('href', $(this).attr('href') + '?sicksheet=true'); else $(this).attr('href', $(this).attr('href') + '?sicksheet=false'); }); }); &lt;/script&gt; </code></pre> <p>Basically, when you click on the Process actionlink, the jquery looks for a checkbox with matching ID, then if it's checked, it puts a <code>?sicksheet=true</code> at the end of the url before continuing.</p> <p>edit:</p> <p><strong>ROUTE</strong>:</p> <pre><code>routes.MapRoute("ProcessSickLeave", "process/processsickleave/{applicationid}", new { controller = "Process", action = "ProcessSickLeave" }); </code></pre> <p><strong>CONTROLLER</strong>:</p> <pre><code> public ActionResult ProcessSickLeave(ProcessViewModel m) { return Content("ID = " + m.ApplicationID + "&lt;br/&gt; Has Sick sheet: " + m.SickSheet.ToString(), "text/html"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload