Re: javascript

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



darren wrote:
> I have a form that resides within a php function().  And, I would like
> to call a javascript function from an "onChange" event of a
> <selection> tag (a drop down list box).
>

Your page's problem is entirely a Javascript problem. Has nothing to do with PHP:

Try moving the "onchange" from the <option> tag to the enclosing <select> tag. (It is the value of the <select> that changes when a different <option> is selected.)

Now for the lecture:

> Is there any problem with trying to call a javascript function from
> within a php function?

Yes, it's impossible. PHP is executed on the server. Javascript is executed in the browser. So Javascript cannot be called from PHP running on the server.

PHP is a document generator. You can use it to generate Javascript the exact same way you use it to generate HTML. But the resulting Javascript won't be executed till it gets to the browser.

The main problems you'll have generating Javascript from PHP are:
--keeping control of all the embedded quotes.
--keeping control of the embedded logic (and remembering to remember that the Javascript part isn't being executed just yet :)

Regards,

-J

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux