I want to use php function in the java script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rangana
Forum Newbie
Posts: 6
Joined: Thu Sep 04, 2008 4:36 am

I want to use php function in the java script

Post by Rangana »

Iwant to use php function in the javascript pls help me.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: I want to use php function in the java script

Post by onion2k »

You can't.
iris
Forum Newbie
Posts: 18
Joined: Wed Sep 10, 2008 4:25 am

Re: I want to use php function in the java script

Post by iris »

i hv been made to realise the truth that trying to do somthing even u dont get it will widen ur knowledge.
try writin out some things then u can b corrected, u can always do better than u think. Bro
:D
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: I want to use php function in the java script

Post by onion2k »

iris wrote:i hv been made to realise the truth that trying to do somthing even u dont get it will widen ur knowledge.
try writin out some things then u can b corrected, u can always do better than u think. Bro
:D
"AOL speak" is against the rules here. Don't use it again please.
User avatar
mattcooper
Forum Contributor
Posts: 210
Joined: Thu Mar 17, 2005 5:51 am
Location: London, UK

Re: I want to use php function in the java script

Post by mattcooper »

iris wrote:i hv been made to realise the truth that trying to do somthing even u dont get it will widen ur knowledge.
try writin out some things then u can b corrected, u can always do better than u think. Bro
:D
Yeah, whatever, maybe stick to talking about PHP rather than getting all spiritual?

I think what you want to do is use values that are passed to PHP variables in your Javascript, in which case you can. Simply give your Javascript file a .js.php extension and then use whatever PHP code you want. so, for example:

Code: Select all

 
<script>
//script.js.php
document.getElementById('el').innerHTML = "<?php echo $yourValue ?>";
</script>
 
Have fun :)
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: I want to use php function in the java script

Post by onion2k »

mattcooper wrote:Yeah, whatever, maybe stick to talking about PHP rather than getting all spiritual?
:D
User avatar
mattcooper
Forum Contributor
Posts: 210
Joined: Thu Mar 17, 2005 5:51 am
Location: London, UK

Re: I want to use php function in the java script

Post by mattcooper »

Yar, I find time-wasters ever so tiresome <yawns>
iris
Forum Newbie
Posts: 18
Joined: Wed Sep 10, 2008 4:25 am

Re: I want to use php function in the java script

Post by iris »

Pls wat does "AOL" means? Pls!!!!!
Post Reply