Jump to content

calling javascript from php


cearlp

Recommended Posts

I define a Javascript in the <head> section of a .php file and call it from the <body> section with the following:

echo "<script language='javascript'>function();</script>".

The function displays a confirm box with the normal Cancel and OK buttons just fine, but I want to capture the function return of true or false for which button was selected.

So far I haven't found a way to get return a value from the function. Any ideas???

Link to comment
https://forums.phpfreaks.com/topic/222698-calling-javascript-from-php/
Share on other sites

I wasn't looking at it that way. My flow is like this:

As stated, the function is in the <head> section of the file. A form is displayed and if the submit button is selected the page reloads itself. If  isset($_POST['submit'] is true certain fields are checked for being blank. If they are, an alert box is displayed and the form is re-displayed with the data that has already been filled in. If the fields are not blank processing continues and later in the process flow a database is going to be updated. At this point I want to call a confirm function to display a confirm box and need the response of either OK or Cancel to either continue the update or re-display the form.

Does this make sense?

Archived

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

×
×
  • Create New...

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.