T
T
tamulin302022-04-15 14:21:16
PHP
tamulin30, 2022-04-15 14:21:16

How to add onclick by button id?

There is a form on the wordpress elementor, you need to add to the button knowing its id the metric function when pressed, if it is possible to implement it in PHP it will be cool

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2022-04-16
@Lopar

It's worded a bit badly, but if I understand correctly, and you need to call PHP through onClick, then it won't work without a Javascript sandwich.
php:

function php_func(){
echo "Stay Safe";
}

javascript:
function clickMe(){
var result ="<?php php_func(); ?>"
document.write(result);
}

html: As a result, the ID can be substituted either through Javascript, or even without it, simply by calling the desired function in PHP. But it's all a scam.
<button onclick="clickMe()"> Click </button>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question