Jump to content

function by hitting a button


Le0

Recommended Posts

he there i'm new to PHP and i've got a question, probably someone of you can solve it easiely....

 

i've got a function and i want that this function got "runned" if some hit a button:

my code for define the function (echo "hello world" is just a dummy for a much more complicated command):

 

<?php
function test() {
echo "hello world";}
?>

 

and the button:

<input type="button" value="GO" onClick="test()">

 

mfsg

AX

Link to comment
https://forums.phpfreaks.com/topic/62013-function-by-hitting-a-button/
Share on other sites

php is finished before the client sees the page - one on the client on js is available.

 

Your options are - send a new request loading the page once more but with some data sent (like a form) to use in flow control and call functions you need etc. OR send an ajax request which could run some php code and return some html that your ajax request can place in a specified element...

can't be done with PHP, you may confuse this with java script:

something like this would work

 

<script type="text/javascript" language="javascript">

function test() { alert("hello world!");}

</script>

 

 

and for the button:

<input type="button" value="GO" onClick="test();">

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.