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

php n javascript

Hi
I have a problem while inserting php code into javascript

var danevar1 = '<?php echo $dane1; ?>';

this line doesn't work
i tried also:
var danevar1 = '<? echo $dane1; ?>';
and
var danevar1 = '<?= echo $dane1; ?>';

but it's not working

Can anyone help my with it?
Leszek
Feb 5 '06 #1
4 1262
Leszek wrote:
Hi
I have a problem while inserting php code into javascript

var danevar1 = '<?php echo $dane1; ?>';

this line doesn't work
i tried also:
var danevar1 = '<? echo $dane1; ?>';
and
var danevar1 = '<?= echo $dane1; ?>';

but it's not working

What do you expect it to do? All you have done is create a string.

--
Ian Collins.
Feb 5 '06 #2
Leszek wrote:
Hi
I have a problem while inserting php code into javascript

var danevar1 = '<?php echo $dane1; ?>';

this line doesn't work
i tried also:
var danevar1 = '<? echo $dane1; ?>';
and
var danevar1 = '<?= echo $dane1; ?>';

but it's not working

Can anyone help my with it?
Leszek


are you define $dane prior to sending the header containing the javascript?

Simple test...

---------cut here----------------
<?php $dane = "123";?>
<html>
<head>
<script type="text/javascript?>
function xyz(a){
var='<? echo $dane; ?>'
return true
}
</script></head>
</html>
---------------cut here---------

view source shows:

<html>
<head>
<script type="text/javascript?>
function xyz(a){
var='123'
return true
}
</script></head>
</html>
Works for me, so my guess is that you are not defining $dane before you
are trying to output it...
M.
Feb 5 '06 #3
Ksu
The simplest test
<?php $var=1; ?>
<script>var t=<?php echo $var; ?></script>

Feb 5 '06 #4
Hi.

I didn't have :
<script type="text/javascript?>

</script>

and that was the problem

Thanks for help
Leszek
Feb 6 '06 #5

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

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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...

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.