By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

Javascrip code in php variable

P: n/a
Dan
Hi,

I would like to know if it is possible to insert workable javascript
code into a variable. For example, in php if I say

<? echo $blah; ?> and $blah equals " ?> <script>
top.navi.document.title </script> <?"

I would want the page to act out the code when i tell it to echo the
variable.

If this is not possible, is there a way to set information from
javascript into a php variable?

Also, i would like to know how to use if statements in javascript. For
example, if I have a variable x and i want to see if x equals "test"
and if it does then it caries out some code.

Thanks
Dan

Nov 24 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Dan said the following on 11/23/2005 6:57 PM:
Hi,

I would like to know if it is possible to insert workable javascript
code into a variable. For example, in php if I say

<? echo $blah; ?> and $blah equals " ?> <script>
top.navi.document.title </script> <?"

I would want the page to act out the code when i tell it to echo the
variable.
Did you test it?
If this is not possible, is there a way to set information from
javascript into a php variable?
Before anybody points it out, I am referring to client-side Javascript
and native Server Side PHP.

PHP is server side. It is executed before the browser ever sees it.
JS is client side. It is executed after the browser gets it.
They do not interact without another call to the server.
Also, i would like to know how to use if statements in javascript. For
example, if I have a variable x and i want to see if x equals "test"
and if it does then it caries out some code.


if (condition){
//statements if condition is true
}
else{
//statements if condition is false
}
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 24 '05 #2

P: n/a
Dan wrote:
I would like to know if it is possible to insert workable javascript
code into a variable. For example, in php if I say

<? echo $blah; ?> and $blah equals " ?> <script>
top.navi.document.title </script> <?"
That would be parsed into

?> <script>
top.navi.document.title </script> <?
If this is not possible, is there a way to set information from
javascript into a php variable?
Yes, there is. See
news:11**********************@z14g2000cwz.googlegr oups.com and the
following thread.
Also, i would like to know how to use if statements in javascript.
For example, if I have a variable x and i want to see if x equals
"test" and if it does then it caries out some code.


if (x == "test")
{
// ...
}
PointedEars
Nov 24 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.