473,409 Members | 2,063 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,409 software developers and data experts.

How to Pass PHP variables to JS?

Don
How do I pass PHP variables to JavaScript in the returned browser page?

Thanks,
Don
Jul 17 '05 #1
6 9740
Don wrote:
How do I pass PHP variables to JavaScript in the returned browser page?

Thanks,
Don

Well, you could do this if you have a variable $_POST['name']:
....
some javascript
.....

echo 'var name = ' . $_POST['name'];

....
Just like HTML, but you write valid javascript.
Jul 17 '05 #2
Don
On Mon, 08 Nov 2004 14:04:37 -0600, David Zawislak <da*******@excite.com> wrote:
Don wrote:
How do I pass PHP variables to JavaScript in the returned browser page?

Thanks,
Don

Well, you could do this if you have a variable $_POST['name']:
...
some javascript
....

echo 'var name = ' . $_POST['name'];

...
Just like HTML, but you write valid javascript.


Thanks David. That worked just fine.

Regards,
Don
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 17 '05 #3
Don wrote:
How do I pass PHP variables to JavaScript in the returned browser page?

Thanks,
Don


<?
$hello = "hello";
?>

<script language="javascript">
alert("<?=$hello;?>");
</script>
Jul 17 '05 #4
In article <1100189674./W3ZIuK13gf7EpV3ROowxg@teranews>,
Jeremy Smith <di******@chl.chalmers.se> wrote:

:<script language="javascript">
:alert("<?=$hello;?>");
:</script>

Or (something useful):

<?php
$referred_to = 'http://127.0.0.1/~you/old_browser.php';
?>

<script language="Javascript" type="text/javascript">
if (!document.getElementById) {
top.location.replace("<?php echo $referred_to; ?>");
}
</script>
--
Looks like more of Texas to me.
.... Arizona, where the nights are warm and the roads are straight.
Jul 17 '05 #5
Don
On Thu, 11 Nov 2004 17:14:31 +0100, Jeremy Smith <di******@chl.chalmers.se> wrote:
Don wrote:
How do I pass PHP variables to JavaScript in the returned browser page?

Thanks,
Don


<?
$hello = "hello";
?>

<script language="javascript">
alert("<?=$hello;?>");
</script>

Thanks Jeremy.
Don
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 17 '05 #6
Don
On Thu, 11 Nov 2004 11:45:39 -0500, Warren Oates <Wa**********@Gmail.com> wrote:
In article <1100189674./W3ZIuK13gf7EpV3ROowxg@teranews>,
Jeremy Smith <di******@chl.chalmers.se> wrote:

:<script language="javascript">
:alert("<?=$hello;?>");
:</script>

Or (something useful):

<?php
$referred_to = 'http://127.0.0.1/~you/old_browser.php';
?>

<script language="Javascript" type="text/javascript">
if (!document.getElementById) {
top.location.replace("<?php echo $referred_to; ?>");
}
</script>

Thanks Warren.
Don
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: adolf garlic | last post by:
Suggestions please for strategy to share values across app. Scenario: I have an asp.net app that uses some com components along with .net classes. Configuration settings for various things...
10
by: tshad | last post by:
I want to access multiple arguments based on name passed. For example I have the following asp:textboxes: BillingAddress1 BillingAddress2 BillingCity ShippingAddress1 ShippingAddress2...
7
by: Gladen Blackshield | last post by:
Hello All! Still very new to PHP and I was wondering about the easiest and simplest way to go about doing something for a project I am working on. I would simply like advice on what I'm asking...
6
by: lisp9000 | last post by:
I've read that C allows two ways to pass information between functions: o Pass by Value o Pass by Reference I was talking to some C programmers and they told me there is no such thing as...
12
by: Bryan Parkoff | last post by:
I write my large project in C++ source code. My C++ source code contains approximate four thousand small functions. Most of them are inline. I define variables and functions in the global scope....
13
by: magickarle | last post by:
Hi, I got a pass-through query (that takes about 15 mins to process) I would like to integrate variables to it. IE: something simple: Select EmplID from empl_Lst where empl_lst.timestamp between...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
17
by: Daniel | last post by:
When I use the CreateThread API method, what do I need to do when I want to pass more than one parameter where LPVOID lpParameter is passed? Daniel
21
by: raylopez99 | last post by:
In the otherwise excellent book C# 3.0 in a Nutshell by Albahari et al. (3rd edition) (highly recommended--it's packed with information, and is a desktop reference book) the following statement is...
1
by: kkshansid | last post by:
i want to pass both variables($q1 and value of select) from this php page to java script so that i can get both variables in second php file srt.php <script type="text/javascript"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.