on 27/07/02 12:09 PM, Michael ([EMAIL PROTECTED]) wrote:
> <?php
> function joe() {
> $temp1=10;
> $temp2=20;
> $result=$temp1+$temp2;
> echo "The result of this function is: " . $result;
> }
> ?>
wouldn't that be
return "The result of this function is: " . $result;
rather than echo?
Anyhoo, you haven't specified HOW you want to communicate the result of the
function to the browser.
A HREF is supposed to take you off to another page (amongst other things),
which might be what you're after.
JavaScript (*shudder*) is designed to provide client-side actions, so maybe
a javascript alert is what you want, or a pop-up window, or who knows what.
You need to decide what happens, in a story board fashion.
Remember, everything in PHP code takes place on the server, BEFORE the
browser gets it.
Example of using JS alert:
<HTML>
<?
function joe() {
$temp1=10;
$temp2=20;
$result=$temp1+$temp2;
return "The result of this function is: " . $result;
}
?>
<A HREF="#" onclick="javascript:alert('<?=joe()?>')">calculate foo</a>
</HTML>
but really, I can't understand why you wouldn't just do:
<HTML>
<?
$result=$temp1+$temp2;
echo "Total: {$result}";
?>
</HTML>
Why do they have to click?
You'll have to check all the javascript stuff and maybe massage it, because
I haven't tested this, and haven't written much JS in the past coupla years.
Beware of the limitations of relying on javascript for anything though :)
Justin French
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php