How to use Checkbox as button click event using JQuery/Ajax - MVC2 -


this code output content enter text box display when click button. want lik when select checkbox value entered in text box rendered.

//view page: in page jquery request&responce type , displaying 2 text box , 1 check box , 1 button  <script type="text/javascript">       $(function(){          $('#selectall').change(function () {              alert("value changed");//when run script witht alert function getting output code unable output expect            var options = {         target: '#result-user', // id of div going display result               beforesubmit: showrequest,               success: showresponse,               type: 'post',               resetform: true           };           $('#form-user').ajaxform(options); // id of form wish submit       });   });         function showrequest(formdata, jqform, options) {           $("#result-user").empty().html('loading....');           $("#form-user :input").attr("disabled", true); // disable form inputs while loading       }          function showresponse(responsetext, statustext, xhr, $form) {           $("#result-user").empty().html(responsetext);           $("#form-user :input").attr("disabled", false);       }   </script> </head>  <body>    <% using (html.beginform("index","home",formmethod.post, new { id="form-user", name="form-user"})) {%>        <fieldset>           <legend>fields</legend> <div class="editor-label">               <%= html.labelfor(model => model.firstname) %>           </div>           <div class="editor-field">               <%= html.textboxfor(model => model.firstname) %>               <%= html.validationmessagefor(model => model.firstname) %>           </div>          <div class="editor-label">               <%= html.labelfor(model => model.lastname) %>           </div>           <div class="editor-field">               <%= html.textboxfor(model => model.lastname) %>               <%= html.validationmessagefor(model => model.lastname)%>           </div>           <div>           <input type="checkbox" name="selectl" value="on" id="selectall"/>           </div>           <p>               <input type="submit" value="save" />           </p> 

control page

public class homecontroller : controller {     //     // get: /home/      public actionresult index()     {         return view();     }      [httppost]     public actionresult index(homemodel data)     {         return content("you submitted: " + data.firstname + " " + data.lastname);      }  } 

model page

public class homemodel {     public string firstname { get; set; }     public string lastname { get; set; }  } 

actual output of code display content enter in text box when hit button.but want output when select checkbox content entered in text box should rendered.

please me friends.

ajaxform doesn't submit form. sets form submit via ajax when click submit button.

change ajaxform(options) ajaxsubmit(options). should trick (just tried it, , works).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -