469,612 Members | 2,265 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

FAQ Topic - How do I get a perl/asp/php variable into client-side js?

-----------------------------------------------------------------------
FAQ Topic - How do I get a perl/asp/php variable into
client-side js?
-----------------------------------------------------------------------

Use the server-side language to generate the javascript:

var jsvar="<%= aspvar %>";
var jsvar="<?php echo $phpvar ?>";
===
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers.

Apr 25 '07 #1
3 2009
FAQ server wrote on 26 apr 2007 in comp.lang.javascript:
-----------------------------------------------------------------------
FAQ Topic - How do I get a perl/asp/php variable into
client-side js?
-----------------------------------------------------------------------

Use the server-side language to generate the javascript:

var jsvar="<%= aspvar %>";
var jsvar="<?php echo $phpvar ?>";
This is only for strings, so that c/should be mentioned.

Is a warning for inside quotes or new lines appropriate,
as the variable value is semt to the client as a litteral?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 25 '07 #2
Evertjan. said the following on 4/25/2007 7:09 PM:
FAQ server wrote on 26 apr 2007 in comp.lang.javascript:
>-----------------------------------------------------------------------
FAQ Topic - How do I get a perl/asp/php variable into
client-side js?
-----------------------------------------------------------------------

Use the server-side language to generate the javascript:

var jsvar="<%= aspvar %>";
var jsvar="<?php echo $phpvar ?>";

This is only for strings, so that c/should be mentioned.
While that is strictly true, shouldn't issues of getting quotes to the
browser from PHP/ASP be a PHP/ASP question? Personally, I don't even
think that entry should be there anymore, it is a PHP/ASP question.
Is a warning for inside quotes or new lines appropriate,
as the variable value is semt to the client as a litteral?
Again, to me, it isn't a JS question as much as a PHP/ASP question.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 26 '07 #3
Randy Webb wrote on 26 apr 2007 in comp.lang.javascript:
Evertjan. said the following on 4/25/2007 7:09 PM:
>FAQ server wrote on 26 apr 2007 in comp.lang.javascript:
>>-----------------------------------------------------------------------
FAQ Topic - How do I get a perl/asp/php variable into
client-side js?
-----------------------------------------------------------------------

Use the server-side language to generate the javascript:

var jsvar="<%= aspvar %>";
var jsvar="<?php echo $phpvar ?>";

This is only for strings, so that c/should be mentioned.

While that is strictly true, shouldn't issues of getting quotes to the
browser from PHP/ASP be a PHP/ASP question? Personally, I don't even
think that entry should be there anymore, it is a PHP/ASP question.
>Is a warning for inside quotes or new lines appropriate,
as the variable value is semt to the client as a litteral?

Again, to me, it isn't a JS question as much as a PHP/ASP question.
Agree! [ as long as ASP-jscript is not part of this FAQ. ]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 26 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Kirt Loki Dankmyer | last post: by
4 posts views Thread by Patricia Mindanao | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.