5

I have a form that will collect input from the user and it consist of a button. Once a user click on the button, a pop up message will be shown.

I would like to post the form inputs to the url stated in the javascript.

<div class="live-preview">
     <a class="confirm" id="alert">
     <input type="submit" name="submit" class="btn btn-common uppercase" value="Edit Booking">
     </a>
     <script>
     $(".confirm").easyedit();
     $("#alert").click(function() {
           window.location = "processEditBookSeat.php";
     });
     </script>
     <input name="workshopSeatLeft" type="hidden" id="workshopSeatLeft" value="<?php echo $resultWorkshopDetail['workshopDetailSeatLeft']?>">
     <input name="alreadyBookedSeat" type="hidden" id="alreadyBookedSeat" value="<?php echo $userBookedSeat?>">
     <input name="workshopID" type="hidden" id="workshopID" value="<?php echo $getWorkshopID?>">
</div>
7
  • Where do you want to pass the parameters? In the path, the query part or the fragment part? Can you provide an expected URL? Commented Oct 11, 2015 at 7:14
  • I want to pass it to processEditBookSeat.php under confirming the alert box Commented Oct 11, 2015 at 7:15
  • Meaning something like this : processEditBookSeat.php?workshopID=1234&alreadyBookedSeat=false&workshopSeatLeft=true ? Commented Oct 11, 2015 at 7:19
  • This will result to GET. Is there a way to POST? Commented Oct 11, 2015 at 7:20
  • Yes there is a jQuery post method, takes as argument the URL, a plain object (name, value) and some callbacks for the state (on success on error ...) Commented Oct 11, 2015 at 7:23

2 Answers 2

2

If you want to submit the form using post to a specific adress and therefor direct to this address use

$('#form').attr('action', "/yoururl").submit();

If however you want to post it in the background use

$.post(url, $('#form').serialize());
Sign up to request clarification or add additional context in comments.

Comments

1

You can either create an Ajax request and on success to redirect the page or you can submit a form as in the old days.

If you can alter the HTML, than wrap the inputs into a form with the action set to processEditBookSeat.php and set also an ID like "bookSeatForm" to it so its easyer to find in js side.

Then modify the script like so:

  $(".confirm").easyedit();
  $("#alert").click(function() {
       $("#bookSeatForm").submit()
   });

Further if this method suits you why not use the default form behaviour and change the #alert element to a submit input ? That is up to you.

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.