Jump to content

Archived

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

duncanhall

Calling "sendRequest"

Recommended Posts

At the moment I'm calling all my javascript from links and buttons with [i]onclick="sendRequest('$variable')"[/i].

Is there a way to call [i]sendRequest()[/i] from straight within the php code?

i.e:

[code]If ($x == $y) {
    // call sendRequest()
}[/code]

Share this post


Link to post
Share on other sites
..... not sure exactly what you mean, but you can't call a javascript function from PHP.  PHP executes on the server... javascript executes on the client.  Those are 2 different times.

Share this post


Link to post
Share on other sites
just a supplement to ober's post....

if there is a criteria met in your php code then you could then place

echo 'onLoad="sendRequest(\'' . $variable . '\')"';

inside the body tag.

Alternatively you could use futher js to call the send request based on what the user has entered into the form.

say u have two text boxes and you want to send the request when the 2 values are equal then right another function that checks to the 2 values (and they are not empty) if they are eaual call sendrequest. Then simply add the onChage or onKeyUp attribute of the input field pointing to your new script.

Share this post


Link to post
Share on other sites

×

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.