- Add a hidden field. HTML. Copy Code.
- Then, on the backend / php side, you can write something like below to get the button innerText.
- Display the variable using document. write() method.
- Display the variable to an HTML element content using innerHTML property.
- Display the variable using the window. alert() method.
Do you want to give a JS value to PHP?
You sure you want to give a JS value to PHP? PHP doesn’t work on client side. What you are making will give that php the value only for once from your code. It wont give it to php live on client side like that – Hanky Panky Feb 7 ’14 at 5:42 Learn about forms to send data to PHP easily and than learn AJAX for dynamic data exhange. – Shiva Avula