Skip to content
Advertisement

How to pass the id of a client by a html button in javascript

here’s my problem:

I’m making a client system in javascript and php.

I would like to be able to delete the account of a customer who has a unique identifier (id=x) by clicking on a “Delete Customer” button.

JavaScript

The problem is that to bring a little dynamism, I treat the request in javascript in this way:

JavaScript

My request is as follows:

I would like to recover the customer id ($clientinfo[‘id’] in php) and the administrator id ($login[‘id’] in php) in javascript to execute the request.

Could you help me?

Advertisement

Answer

add attribute data-id your a tag

like this:

JavaScript

remember: 12 is example, you should load id dynamically by php

and get in your Listener . like this:

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