jquery - Set checkbox value on submit ASP.NET MVC -


i have asp.net mvc view checkbox in form. there way change checkbox value when submit button clicked?

i have form 2 text inputs , checkbox. have 2 submit buttons, when submit 1 clicked want submit form is. but, when submit 2 click want automatically set checkbox checked , post form controller.

is there way this? in view or javascript?

there 2 way solve this. first can set event on click on second button

<input name="submit" type="submit"  id="justsubmit"/> <input name="submit" type="submit" onclick="checkedcheckbox()" id="submitwithcheckbox"/> 

on javascript

function checkedcheckbox() {    $('#mycheckbox').prop('checked', true); } 

second 1 using server side. can name both of submit button validate , change value checkbox based on submit button pressed.

<input name="submit" type="submit" id="submit" value="save" /> <input name="submit" type="submit" id="process" value="process" /> 

and in controller can validate submit button check

public actionresult index(class model, string submit) {    if(submit == "process")    {         model.checked = true;     } //if not...     return view(); } 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -