0

I am disabling some elements and enabling those elements while submitting form. So that i can submit those values. but i can't find values in action class but elements are getting enabled.

As i am using jquery 1.4.4 version i can't use .prop() method.

here is the code to disable the element:

$("#"+index+'_procStepTitleAutoSuggest').attr("disabled","disabled");
$("#"+index+"_crtRowActiontxt").attr("disabled","disabled");
$("select#"+index+"_stepFunction").attr("disabled","disabled");
$("input#"+index+"_stepRTime").attr("disabled","disabled");
$("#"+index+"_donotchkBox").attr("disabled","disabled");
$("select#"+index+"_applicableAccessTime").attr("disabled","disabled");

Here is the code(enabling elements) while submitting form:

    $('form').submit(function(){
$("#procedure_main_div_container").find("input,select,checkbox").attr('disabled', false);
})

Please help me. Thanks in advance.

sanjitguin
  • 47
  • 1
  • 12
  • I'd say that the form selects what to send before your script enables them again. But there's not much code here, it's hard to say exactly what is there to change. Try disabling the defalut action of the button, enabling your field, and then submitting the form "manually" by JavaScript. – Kewin Dousse May 10 '17 at 13:12
  • 2
    Why not use hidden fields and show only text to user (if needed)? – Justinas May 10 '17 at 13:13
  • Duplicate of http://stackoverflow.com/questions/1355728/values-of-disabled-inputs-will-not-be-submited – Sagar May 10 '17 at 13:14

3 Answers3

4

You can not post disabled element value in form. just You can change your disabled to readonly attr

Jay
  • 703
  • 9
  • 21
1

Instead of this:

$('form').submit(function(){
  $("#procedure_main_div_container").find("input,select,checkbox").attr('disabled', false);
})

Try this:

$('form').submit(function(){
  $("#procedure_main_div_container").find("input,select,checkbox").each(function() {
    this.disabled = false;
  });
});

Edit: I see the problem. attr('disabled', false) is not doing what you expect. Mine or the other answer should work.

Matthew
  • 8,183
  • 10
  • 37
  • 65
  • Thanks for your answer @Matthew. Actually .attr() is working properly in upper versions of jquery. But in jquery1.4.4 it isn't working. even "this.disabled=false" is also not working. – sanjitguin May 11 '17 at 03:35
1

you can use this to remove the disabled attribute for all your selectors

$('form').submit(function(){
    $("#procedure_main_div_container").find("input,select,checkbox").removeAttr('disabled');
})
RAUSHAN KUMAR
  • 5,846
  • 4
  • 34
  • 70