TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-21-2008, 01:32 AM   #1 (permalink)
The Wanderer
 
Join Date: Apr 2008
Posts: 15
Thanks: 0
kororo203 is on a distinguished road
Default can i incorporate javascriptin php?

don't know where to postthis but i yhink it ismore aboout php..

i need some clarifications...
lets say that i have a javascript function..
<script>
var i =0;
function xxxx ()

{

if (i == 1)
php expression }
else if (i == 2)
php expression
}
</script>

is this possible?

thanx...
kororo203 is offline  
Reply With Quote
Old 04-21-2008, 01:39 AM   #2 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

What? This forum is for php, not javascript, I suggest a mod to move this to the javascript forum. oh and no, must be in the scope.

Also, you can put javascript in php, just do an echo or print | printf

PHP Code:
$js=array();
$js[0]="<script>
var i =0;
function xxxx ()

{

if (i == 1)
php expression }
else if (i == 2)
php expression
}
</script>"
;

printf('%s',$js[0]);


#You can also do an sscanf and format it into another variable
#without it outputting
$f_js sscanf($js[0],'%s'); 
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 04-21-2008, 01:46 AM   #3 (permalink)
The Wanderer
 
Join Date: Apr 2008
Posts: 15
Thanks: 0
kororo203 is on a distinguished road
Default

but how bout vice versa?

inside the java script is a php script? can that be possible and how because i think document.write doesn't work for it...
kororo203 is offline  
Reply With Quote
Old 04-21-2008, 01:46 AM   #4 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by kororo203 View Post
but how bout vice versa?

inside the java script is a php script? can that be possible and how because i think document.write doesn't work for it...
no javascript is client side, php is server side, it's impossible.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 04-21-2008, 01:51 AM   #5 (permalink)
The Wanderer
 
Join Date: Apr 2008
Posts: 15
Thanks: 0
kororo203 is on a distinguished road
Default

thanx.. than ill just use javascript inside php statements
thanx for the help...
kororo203 is offline  
Reply With Quote
Old 04-21-2008, 01:53 AM   #6 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by kororo203 View Post
thanx.. than ill just use javascript inside php statements
thanx for the help...
Yeah, that's what PHP is good for, just add the php variables in the javascript strings. :) like so

PHP Code:
$var2="var bar = \"foo\";"
$var="<script>$var2</script>"
this would output $var2 into the quotations, it's good. :]
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:01 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design