473,320 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Javascrip code in php variable

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
2 2376
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Terje Sæternes | last post by:
It seems that this script wont run, any idea what I have don wrong+ Code----- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title>...
5
by: Jean Pion | last post by:
Dear readers, Can I use the following object on a Linux based web server: var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); If not, is there a compatible object? Tia, Jean.
3
by: Gerhard Hönig | last post by:
Hi, i have a basic question on CSS. Is it possible to change the CSS class definition dynamically by using Javascript. example: ich have a css class like this one: ..test {
0
by: Robert Ladd | last post by:
Hi, I'm trying to disable the asp.net calendar control from a javascript function, but it doesn't disable the doPostBack. To simplify the situation, assume a page with 4 controls. A...
7
by: annoyingmouse | last post by:
Is it possible to use javascript to add javascript to a DOM object? I've the following code to add an image to a page: function flagError(id){ var image = document.createElement('img');...
1
by: ♥eXtreme oXygen♥ | last post by:
How do i call JAVASCRIP function from an event of ASP.NET:BUTTON, if runat=server attribute is true... actually i want to open an popup window using asp.net--button onclick event, but its not...
3
by: Brett Wesoloski | last post by:
I can not seem to figure this out, but really haven't work a lot with javascrip and .NET. I have a data grid and I want to put a button in it and when the button is pressed it will call my...
5
by: mmr315 | last post by:
how to call javascript variable in to phpcode in the same form please help me how to call
1
by: lathamoulali | last post by:
Hello Frnds, I am new to the ASP.NET Programming.Please help me out with this problem. I have a page_load() method in which i have to invoke the javascrip's alert method.I am using inline...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.