c# - MVC3 Count of checked Checkboxes -
In my view, I want to see the check check box count in an editor field! How can I keep my request?
Controller: How do I change that controller? //
create public actions () {Return View (); } // // Post: / project / create [hppost] create public action roles (PPM_ Project project) {if (ModelState.IsValid) {db.Project.Add (project); Db.SaveChanges (); Return Redirect Action ("Index"); } ViewBag.Status = new selection list (new string [] {"----------", "running", "hold", "end", "did not start", "cancel"} ); See return (project); } See: What's the change in the scene?
& lt; Div class = "editor-label-AI" & gt; @html Labelfire (model => model enzahoglotrophinebiu annehtenen) & lt; / Div & gt; & Lt; Div class = "editor-field-AZB" & gt; @html Editor (Model = & gt; Model.Azahl_bprprofin_unhighten) @html Validity message (Model = & gt; Model. Enzahlog Atropinebiunethethane) & lt; / Div & gt; I want to check the check checkbox count!
Thanks for the help!
provided I understand your question correctly: how many checkboxes you update to check The text box is required for ...
You have to do this in JavaScript, if you are using MVC, I have an example whip that shows this functionality that might be easily optimized in your project It is possible.
< P> HTML & lt; Input type = "checkbox" /> & Lt; Input type = "checkbox" /> & Lt; Input type = "checkbox" /> & Lt; Div class = "editor-field-AZB" & gt; & Lt; Input id = "count" value = "0" /> & Lt; / Div & gt; & Lt; Input type = "checkbox" /> & Lt; Input type = "checkbox" /> & Lt; Input type = "checkbox" /> JavaScript var countInput = document.getElementById ('count'); Var checkbox = document.querySelectorAll ('input [type =' "checkbox"] '); (Var i = 0; i & lt; checkbox length; i ++) {checkbox [i] .change = countCheckboxes; } Function countCheckboxes () {var number = 0; (Var i = 0; i & lt; checkbox length; i ++) {if (checkbox [i] is checked) calculation ++; } CountInput.value = Calculation; } CountCheckboxes ();
Comments
Post a Comment