Jump to content

can you use php in a javascript file?


jwk811

Recommended Posts

If you want to generate javascript using php, then yes you can.  Just set your script tag to point to the php script, and have your php script output javascript.

But there is no way to "include" a php file from plain javascript.  Like Toon said, you can use ajax to call a php script from javascript and get the results.
Link to comment
Share on other sites

ok say i want to check a form to see if there is input  in each place.. id put onSubmit="check.js" and in the check .js file i can have php in it? and how could i get it to out put an alert if there was no input? could you please give me something to look at? thank you
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.