+ 1
Just as someone can call a JS function on html, can it be done on php?
Calling JS functions
2 Answers
+ 3
Do you mean call a JS fonction through PHP ? If that well you simply have to echo your JavaScript.
ex:
<script>
//some Js before
var test = $("#input").val();
var feedback = function(fb) { $("error").text(fb) };
<?php
echo '
if(test.length === 0){
feedback("empty input !");
}';
?>
//some Js after
</script>
+ 3
only pointing out that it is considered bad practice.