473,385 Members | 1,357 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,385 software developers and data experts.

PHP variables in javascript ?


Am I being a bit dense again?
How do I use variables created in PHP with javascript?
tony
Jun 6 '06 #1
3 1226
Rik
to**@tony.com wrote:
Am I being a bit dense again?
How do I use variables created in PHP with javascript?


Echo them in a script block to the HTML.

$variable = 'something';

echo <<<JS
<script type="text/javascript">
var myVar = '$variable';
</script>
JS;

Grtz,
--
Rik Wasmus
Jun 6 '06 #2
Is this what you mean???

eg. <body onload="alert('<?php echo $php_variable; ?>')">

Jun 6 '06 #3

Thanks pieter and rick... both useful to me.
If there are other ways I'd be happy to see them too.

thanks

tony
Jun 6 '06 #4

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

Similar topics

16
by: Craig L | last post by:
I use ASP to obtain data from a database and I have a piece of javascript code I use on my website. I want to use the database variables in my javascript. I'm not very familiar with javascript, but...
2
by: Craig L | last post by:
This is a solution followup to a request for help posted on 11/04/03 at 12:51pm titled "Using ASP Variables". Here is how you can make ASP variables available for use in Javascript code. I hope you...
3
by: mr_burns | last post by:
hi, i was wondering if anybody could tell me when a function is called and variables are defined within that function, are the variables global where i can call and modify the variables in other...
8
by: lawrence | last post by:
I'm learning Javascript. I downloaded a script for study. Please tell me how the variable "loop" can have scope in the first function when it is altered in the second function? It is not defined...
7
by: jab3 | last post by:
Does JavaScript have "static" variables. That is, as in C (or local in Perl)? How can I keep a variable in a JavaScript function that doesn't change from call to call? It may not make sense in...
1
by: stephane | last post by:
I have a problem which must be in this : print" <script type='text/javascript'> document.location.replace('http://127.0.0.1/add_task.php?req_id={$maxValue}&tk_request_name={$req_name}');...
8
by: mantrid | last post by:
Hello I have the following code, where clicking yh1r is supposed to move h1 10px down and update the value of yh1 by 20 each time its clicked. what the code actually does is NOT move h1 and...
3
by: Vic Spainhower | last post by:
Hello, I have an HTML table that is being constructed from a MySQL table and displays a form that includes a check box on 1 of the fields on the form for each record. I have included in this PHP...
0
by: rpjd | last post by:
Apache2 over XP Home, PHP5, PostgreSQL8.2 If this is not the correct forum for this, it can be reposted accordingly. I have php variables/arrays that I want to display in a php webpage. What I am...
3
by: q-rious | last post by:
Hello All, 1. I would like to pass some variables (x and y below) from Javascript to PHP, process them in PHP, and return some other variables (a abd b) back to Javascript. --(x,y)--...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.