+ 1

Just as someone can call a JS function on html, can it be done on php?

Calling JS functions

13th Apr 2017, 6:49 AM
Kenneth Kahura
Kenneth Kahura - avatar
2 odpowiedzi
+ 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>
13th Apr 2017, 7:24 AM
CHMD
CHMD - avatar
+ 3
only pointing out that it is considered bad practice.
13th Apr 2017, 8:16 AM
seamiki
seamiki - avatar