duncanhall Posted October 2, 2006 Share Posted October 2, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/22740-calling-sendrequest/ Share on other sites More sharing options...
ober Posted October 2, 2006 Share Posted October 2, 2006 ..... 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. Quote Link to comment https://forums.phpfreaks.com/topic/22740-calling-sendrequest/#findComment-102294 Share on other sites More sharing options...
ToonMariner Posted October 2, 2006 Share Posted October 2, 2006 just a supplement to ober's post....if there is a criteria met in your php code then you could then placeecho '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. Quote Link to comment https://forums.phpfreaks.com/topic/22740-calling-sendrequest/#findComment-102324 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.