NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page insert php code into javascript

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 02-10-2004, 06:26 PM THREAD STARTER               #1 (permalink)
Senior Member
 
Crusader's Avatar
Join Date: Aug 2003
Location: Canada
Posts: 1,257
Crusader is just really niceCrusader is just really niceCrusader is just really niceCrusader is just really nice
 



insert php code into javascript


I've made a javascript and would like to know how to echo a value into the script.

Code:
iView.document.body.innerHTML = '<? echo $source; ?>';
that just pastes it as "<? echo $source; ?>".

Any ideas?
Crusader is offline  
Old 02-13-2004, 04:23 PM   #2 (permalink)
Senior Member
Join Date: Aug 2002
Posts: 1,255
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
 



That should work if $source has a value. It should replace $source with whatever it's value is.

So if you had something like:

PHP Code:
<?
????: NamePros.com http://www.namepros.com/code/20183-insert-php-code-into-javascript.html
$source 
"YourValue";
?>

iView.document.body.innerHTML = '<? echo $source?>';
The result should be:
Code:
iView.document.body.innerHTML = 'YourValue';
You can also do it as <?=$source?> for a little shortcut.

If it's just printing out <? echo $source; ?> then you may not have the short_open_tag enabled.
deadserious is offline  
Old 02-18-2004, 08:23 AM THREAD STARTER               #3 (permalink)
Senior Member
 
Crusader's Avatar
Join Date: Aug 2003
Location: Canada
Posts: 1,257
Crusader is just really niceCrusader is just really niceCrusader is just really niceCrusader is just really nice
 



source did have a value...
i registered it as a session too.
Crusader is offline  
Old 02-20-2004, 12:53 PM   #4 (permalink)
Senior Member
Join Date: Aug 2002
Posts: 1,255
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
 



Well like I mentioned above maybe your short_open_tag isn't enabled or something if you're sure their was a value in the variable. It could also be a problem with register_globals or the way you're assigning the value or something like that. Otherwise it would print it to the browser just like you expect. I would need to see how you're getting the values and such to see what's really going on.
deadserious is offline  
Closed Thread


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


 
All times are GMT -7. The time now is 02:45 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger