Jump to content

[SOLVED] Using a PHP variable for js function


blackcell

Recommended Posts

I want to loop through a small database.  For each record in the database I am going to display (in a table):

 

record1    note1

record2    note2

record2    note3

record3    note4

record4    note5

record5    note6

 

When I onmouseOver the record# I want to show a picture for record#

 

I can easily do this with php and using like a "Picture Link" that is associated with the record#.png and it works.  I have done it a million times but I am new to jscript and I don't know quite how to do it.  What I have so far:

 

<script type="text/javascript">
function mouseOver(imageName)
{
document.b1.src = imageName;
}
</script>

<? My Loop begins here assigning variables ?>

<html>
<table>
<tr>
<td onmouseOver="mouseOver(<? echo "$record_number.png" ?>)" align="left"><? echo $recordnumber?>
</tr>
</html>


<? My Loop ends here ?>

After a simple test I found that my html table header row will work fine with the jscript, but the rows that are populated by my loop that is pulling information from a mysql database will not work.  Even when I use two simple pictures with no variables. Anybody got anything?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.