Basically I have some code which needs to be executed server side, I’ve negated it from this and used a simpler example, as it isn’t necessary for you to traul through my server side code.
I want to have a button execute a php function server side, which, you cant do, so I had the button execute some JavaScript to execute the php function as below; im looking to create a generic javascript function with i can use to execute a generic php function like onclick=javascriptfunction(phpfunction)
The script below has no problems calling the php function which then prints hello onscreen (tested),
button calls echoHello() from the script > echoHello() calls the php function hello()
[code]<?php
$a=“hello”;
function hello()
{
global $a;
echo $a;
}
?>
Say Hello[/code]
however;
Can anyone tell me why this code fails, I want to use the code exactly as above but be able to define the php function I wish to call
button calls echoHello(hello) > script should run with $varialble = hello , but it doesn’t or am I doing something wrong.
[code]<?php
$a=“hello”;
function hello()
{
global $a;
echo $a;
}
?>
<button onclick=“echoHello(“hello”)”>Say Hello</butto
n>[/code]