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 ?>

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.