php and javascript

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


Is there any particular reason why JavaScript included in php include page
does not work? Will this be a browser security issue? It works with FireFox,
but not with IE, which I suppose supports the browser security argument.

I've found it is a general JavaScript problem, but an example is:


echo "<img src='../images/go.jpg'
onclick='javascript:document.search_form.submit()' alt='go'
style='margin-left: .2em; vertical-align: top; '>";

There are other ways to use an image as a submit button, I realise, and
maybe I should just ditch the JavaScript, but it is an unexpected problem.

Many thanks

Re: php and javascript

Quoted text here. Click to load it

Does the JavaScript work when placed in a simple HTML page? That will help
narrow down whether the problem is the JavaScript or the PHP code outputting

Re: php and javascript

Joe Blow ( decided we needed to hear...
Quoted text here. Click to load it

No reason why Javascript echo'd from PHP shouldn't work. JS is client
side, not server side.
If it works in FF but not IE, then you probably have execution of JS
turned off in IE.

(Remove REMOVE for email address)

Re: php and javascript

Quoted text here. Click to load it

No, php is serverside and generates something for a client, it's up to
the cleint to interpret is if it's a correct syntax thingy.

Quoted text here. Click to load it

Not a complete, standalone example.... the actuall error could be
anyware in the excluded source... (but the 'javascript:' is totally
unnecessary here).

Quoted text here. Click to load it

This is useless use of javascript indeed, take a look at the input
element's specs. There is a specific value to the type attribute that
allows an image as submit button!

Site Timeline