0

jQuery Submit is not submitting value of button on .submit();

I just wanted to show a confirm bootstrap popup onclick of submit btn.

But using jQuery .submit() form element "Submit" value is empty.

HTML markup:

<form class="form-horizontal" rel="opsform" data-validate="true" role="form" name="frmsetsku" id="frmsetsku" method="post" novalidate="novalidate">
//my input elements

<button class="btn btn-primary btn-sm mr6 " name="Submit" id="btn-action-save" value="Save" type="submit" onclick="return submitSku();"><i class="fa fa-floppy-o bigger-115 ace-icon"></i>Save</button>

</form>

jQuery code:

function  submitSku() {
    event.preventDefault();
    bootbox.confirm("This Will Delete All Previous SKU and add Newly Entered SKUs ", function(result) {
        dialog = this;
        if(result) {
            document.getElementById("frmsetsku").submit();
        }
    });
}

PHP code:

$submit = initRequestValue('Submit');
//my initPostValue allows me to take post value by name

If I remove jQuery, the code is working fine but I add my jQuery submit value is not received.

3
  • Why do you need the form? You can use the HTML tag button only to trigger the operation. I could not see which PHP handles the submit? Commented Jun 5, 2020 at 19:08
  • Where are you initializing the bootbox object? Commented Jun 5, 2020 at 19:10
  • If you are using the onclick event to submit the form, then change the button type to button, instead of submit. Commented Jun 5, 2020 at 19:15

1 Answer 1

0

The <button> element, having the "button" value in its type attribute, instructs the browser to provide a regular button which has no associated action. Its effects must be controlled by something else e.g. JavaScript onClick

Since you are using the Javascript onClick event to submit the form, change the button type to button.

<form class="form-horizontal" rel="opsform" data-validate="true" role="form" name="frmsetsku" id="frmsetsku" method="post" novalidate="novalidate">
    <button class="btn btn-primary btn-sm mr6 " name="Submit" id="btn-action-save" value="Save" type="button" onclick="return submitSku();"><i class="fa fa-floppy-o bigger-115 ace-icon"></i>Save</button>
</form>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.