Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing form value to javascript url

Tags:

java

post

forms

php

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>
like image 221
beny lim Avatar asked Oct 19 '22 00:10

beny lim


1 Answers

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());
like image 84
Bas van Stein Avatar answered Oct 21 '22 16:10

Bas van Stein