So you want to load Page A, click on a link, stay on Page A, but execute a
function located in a script on Page B, without leaving A????
I've never done it, but I believe you call a javascript function which can
do it I think... maybe it's a POST form... sorry I can't be more help, but
I've never needed to do it.
If you can live with the page refreshing, then there's heaps of options.
Justin
on 27/07/02 12:43 PM, Michael ([EMAIL PROTECTED]) wrote:
>
>
> Hi, Justin.
>
> Thanks very much for the reponse.
> Yeah, this is a SUPER simplified form of my question, so please don't
> expect it to make sense. Heh.
>
> Basically, I have a php file with dozens of functions in it. I want ONE of
> them to get called when a link is clicked.
>
> Currently, I achieve this with the use of HTML forms. My form generates a
> list of options. And the user has to select an option, then click the
> SUBMIT button.
>
> But I want to make it a one-step process, whereby the user only needs to
> click on the option.
>
> Of course, you can't achieve this in a form with JavaScript, but the
> JavaScript code won't let me execute a server-side php function
> (obviously).
>
> And I don't want to just shoot the link off to another page (even though
> that's what it was designed to do). I want to call a very specific
> function.
>
> Tricky, I know. :(
>
> -- Michael
>
> On Sat, 27 Jul 2002, Justin French wrote:
>
>> Date: Sat, 27 Jul 2002 11:35:23 +1000
>> From: Justin French <[EMAIL PROTECTED]>
>> To: Michael <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
>> Subject: Re: [PHP] calling user-defined php functions from <a href> tag
>>
>> 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
>>
>>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php