javascript - Unable to post form in mvc -


brief description: on form can either select predefined associate , save it, or create new 1 , save it, cannot both simultaneously. predefined associates presented in drop-down list.


.html

<form id="_jqformassociate">    <select id="associateid">       <option value="">-- select --</option>       <option value="1">associate_1</option>       <option value="2">associate_2</option>       <option value="3">associate_3</option>    </select>     <div id="_jqdisablepanel">       <input id="firstname" type="text">       <input id="lastname" type="text">       <input id="dob" type="text">    </div> </form> 

jquery

$(document).on("change", "#associateid", function(){    // if associate selected drop-down list    // (value of selected option numeral greater 0),    // disable "#_jqdisablepanel" else, enable it.     // disabling "#_jqdisablepanel"    // input fields within must    // cleared/reset default,    // used following:     var panel = $("#_jqdisablepanel");    (panel.find("input")).val("");    (panel.find("select")).val("");    (panel.find("textarea")).val(""); }); 

problematic case

  1. we created record selecting option drop-down list
  2. we want edit record created in 1st-step(with preselected associate , rest other fields empty obviously).
  3. in order need select nothing(means selecting -- select -- option in return enable panel).
  4. now able insert values in text fields manually , save.
  5. when on hitting save button nothing happened(submit button did highlighted though).

later figured out because of code, added reset _jqdisablepanel


solution

$(document).on("change", "#associateid", function(){        // needed use following        // if condition added        // resolve problem.         if($("#_jqdisablepanel").is(":enable")) {           var panel = $("#_jqdisablepanel");           (panel.find("input")).val("");           (panel.find("select")).val("");           (panel.find("textarea")).val("");        }     }); 

what got this: realize jquery code not reseting enabled input fields reseting them when disabled, , reason holding form being posted.

question

what happened on using (panel.find("input")).val("") while input fields disabled stopped form being posted?


this isn't actual form, as not have access code, i've given best explain scenario(i think so...).


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -