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
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...

Link to comment
Share on other sites

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();">

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.