Re: calling javascript
| From: | Garth Hapgood - Strickland | Date: | Mon, 01 Nov 2004 14:52:48 +0000 |
| Subject: | Re: calling javascript | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-200835@lists.php.net to get a copy of this message | ||
Thanx for your help, I am actually a web designer!
I dont think u understand 100%
I have a form and Im doing a check on submission to check whether there are
any blank field and if there are I want to call function.. error_popup();
does this make anymore sense to you. Now I understand that you cant call
javascript from within php. wot would you recommend as an alternative.
I dont have a button or anything that I want to press, just want to call the
function so it can open a popup window.
Regards
Garth
"Ben Ramsey" <lists@benramsey.com> wrote in message
news:41864986.60101@benramsey.com...
> Garth Hapgood - Strickland wrote:
> > by saying ?
> >
> > echo error_popup();
> > or
> > print error_popup;
>
> As someone mentioned, you cannot call a javascript function from within
> PHP. What is meant by client side/server side is this: PHP is processed
> on the server before sending any content to the browser; that's
> server-side. Then, the server sends the HTML output of the PHP script to
> the browser. Any javascript you have in the output is enacted in the
> browser (client-side).
>
> So, you want your PHP to output the javascript just like it might output
> HTML:
>
> i.e.
>
> echo '<script type="text/javascript">';
> echo 'function error_popup() { newwin =
> window.open("error_popup.php","sss","height=470,width=450")
> }';
> echo '</script>';
> echo '<input type="button" onclick="error_popup()">';
>
> Sounds to me like you need to go back and revisit the introductory pages
> of the PHP manual. Take a look at
> <http://www.php.net/introduction> and
> follow the subsequent pages to read more about PHP and what it can do.
> It'll also take you through a tutorial that's fairly helpful.
>
> --
> Regards,
> Ben Ramsey
> http://benramsey.com
>
> ---------------------------------------------------
> Atlanta PHP - http://www.atlphp.org/
> The Southeast's premier PHP community.
> ---------------------------------------------------