slindsey3000
slindsey3000

Reputation: 4271

Form not being submitted after processing click event for submit button

The button is disabled after the click and the text changes, but the form is not submitted. Any ideas why?

$(document).ready(function(){
    $('.pick-button').click(function(){
      $(".pick-button").prop("disabled", true);
      $(".pick-button").prop("value", "PROCESSING. Please wait up to 10 seconds.");
      return true;
    });
  });

Upvotes: 0

Views: 334

Answers (1)

Aaron Christiansen
Aaron Christiansen

Reputation: 11807

From your code, it seems like you're trying to do something on a form's submit button being clicked, and then submit it. First, give your form an id if it doesn't already have one:

<form action="www.example.com" id="my-form">
    ...
</form>

Then add a $("#<form-id>").submit(); call to your JavaScript after your attribute changes:

$(document).ready(function(){
    $('.pick-button').click(function(){
      $(".pick-button").prop("disabled", true);
      $(".pick-button").prop("value", "PROCESSING. Please wait up to 10 seconds.");
      $("#my-form").submit(); # New function call
      return true;
    });
  });

This will force jQuery to submit your form.

Upvotes: 1

Related Questions