I want to send a php variable when calling a javascript function. This way:
href="javascript:calcular($valor1)"
I try to do this, it does not seem to work. Is there any other way to do this?
I want to send a php variable when calling a javascript function. This way:
href="javascript:calcular($valor1)"
I try to do this, it does not seem to work. Is there any other way to do this?
Just print the variable using the echo
href="javascript:calcular(<?php echo $valor1; ?>)"
Hello, I would do so:
function calcular(element){
var variavel = $(element).data('var');
}
<a data-var="<?= $calcular ?>" onClick="calcular(this)">Clique</a>