472,799 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,799 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 9720
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"...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.