Javascrip code in php variable

D

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
 
R

Randy Webb

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
}
 
T

Thomas 'PointedEars' Lahn

Dan said:
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 said:
If this is not possible, is there a way to set information from
javascript into a php variable?

Yes, there is. See
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top