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

How to pass the php variable into Javascript..?

i have php variable which has to be passed inside the javascript...

this is my code..

Expand|Select|Wrap|Line Numbers
  1. <ul class="frnd_lst">
  2. <?php
  3. for($i=1; $i<11; $i=$i+1)
  4. {
  5. ?>
  6. <li id="color" class="frnd_lst_li" onmouseover="color_in()" onmouseout="color_out()">
  7. <div align="left" style="float:left; margin:5px;"><a href=""><img src="Images/9tharasample.png" alt="" /></a></div>
  8. <ul class="namelist1">
  9. <div align="left" class="linespace1" style="float:left;"><!------ ----------></div>
  10. <li class="dob1"><div style="float:left; text-align:right; width:10px;"></div><a href="">Siva Sundharam</a></li>
  11. <li class="dob"><div style="float:left; text-align:right; width:10px;"></div>(Pondicherry, India)</li>
  12. <li class="dob"><div style="float:left; text-align:right; width:10px;"></div>
  13. <a href="">Profile</a> | <a href="">Playlist</a> | <a href="">Friends</a> | <a href="">Quarks</a></li>
  14. </ul>
  15. </li>
  16. <?php } ?>
  17. </ul>
  18. here the javascript
  19. function color_in()
  20. {
  21. document.getElementById("color").styl… = "#DDDBD7";
  22. //document.getElementById("color").sr… = "loading.gif";
  23. //document.getElementById("list").sty… = "#DDDBD7";
  24. }
  25. function color_out()
  26. {
  27. document.getElementById("color").styl… = "#FFFFFF";
  28. //document.getElementById("list").sty… = "#FFFFFF";
  29. }
Now I need to pass the $i variable in js to make that every element of li shows the on mouseover property..
Aug 29 '10 #1
2 1774
TheServant
1,168 Expert 1GB
Please use [code][/ code] tags for when you post code.

PHP can pass variables to Javascript like this:
Expand|Select|Wrap|Line Numbers
  1. <?php $id = "color"; ?>
  2. <html>...
  3. function color_out()
  4. {
  5. document.getElementById(<?php echo $id; ?>).styl... = "#FFFFFF";
  6. }...
Make sense? You should be able to adapt that into your code.
Aug 29 '10 #2
Dormilich
8,658 Expert Mod 8TB
comment on your HTML. <div>s are not allowed inside <ul>/<ol> (ok, anything besides <li> is not allowed)

use a validator to check your HTML code often.
Aug 30 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Stefano | last post by:
Posted: Fri Jan 23, 2004 3:59 pm Post subject: Variable Javascript -------------------------------------------------------------------------------- Hi all, i have a problem with...
5
by: GB | last post by:
Hello: In my MS Access project I have two objects - my form and my report. I need to pass variable value from Command_click procedure of my form to Report_open procedure of my report. How can I...
1
by: Ben Kial | last post by:
I'd like to write a wrapper function "mysprintf(char *buffer, char *format, ....)" which calls sprintf(). My question is how can I pass variable argument in mysprintf() to sprintf(). Thanks in...
1
by: dollar | last post by:
I want to ask what is the best way to pass variable between asp.net we pages, and user controls , any examples - dolla -----------------------------------------------------------------------...
0
by: weiwei | last post by:
Hi; I am having trouble to get variable from grid view. here is my scenario. I want to delete a row in database from web page, in additon, I also want to delete that user's directory in c:drive. ...
1
by: vijaynarang | last post by:
strCmdLine = " " + " -o restore -url " + sSitePath + "/sites/" + sToplevelSiteName + " -filename " + sFileName+ " -overwrite "; process1 =...
4
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on...
12
by: simon2x1 | last post by:
i have a page which is home.php on that page i have a CSS tab which is tab1 and tab2 on that page in both tabs i have a link called next that pass variable to the next page (<a...
7
gskoli
by: gskoli | last post by:
I have created a gif based digital clock but problem is that it will show me the client side time . I am a perl developer so i am getting server time, i mean , i can fetch that time , to pass the...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.