Skip to content
Advertisement

Sending Data from PHP to Javascript to PHP

I don’t understand how to explain my question, but I’m trying to say what I wanted to do.

I have created a modal to submit ‘payment’ for each person. I have created the list of person in a table with PHP loop, and a button against each person so that payment can be done by clicking the button. enter image description here

When I click on the button, a modal popup. enter image description here But how do i understand which person button is pressed. There is unique id for each person. Now, I have to sent the id from button click to my PHP code. How can i do that? Code for creating list of person:

JavaScript

HTML code for creating the Modal:

JavaScript

Javascript code for popup the modal:

JavaScript

I need to sent the respective id & amount from modal code to my PHP code where payment will be processed.

Please help,

Advertisement

Answer

For the “Pay” button, attach a function which gets the ID as a parameter. I assume $sl is the ID you mentioned.

JavaScript

Then, by using the btn() function, Get the ID and add it to the HTML form by using below code:

JavaScript

Then update your HTML Form to bind the UserId to that:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement