Click to See Complete Forum and Search --> : Function onmousever


esapo
02-25-2003, 08:06 PM
Hi!

I am using the following function:

<SCRIPT LANGUAGE="JavaScript">

function mouseover()
{
document.getElementById("mytd").innerHTML="<img src=\"image.jpg\">";
}

</SCRIPT>

If I want to use a Data Base with several images instead of one image ('image.jpg') is it correct to use?

function mouseover()
{
document.getElementById("mytd").innerHTML="<img src=". $row["picture"] .">";
}

where $row["picture"] reference a query on a DB.

I am using the above function but it does not seems to work.

Any help?

Regards,

pyro
02-25-2003, 08:15 PM
Is that PHP? If so, you need something like this:

function mouseover()
{
document.getElementById("mytd").innerHTML="<img src=\"<? $row["picture"] ?>\">";
}

esapo
02-25-2003, 09:24 PM
It started to work, (at least try to show me something) but I dont get the image. Do I have to declare the query in the function? Actually the query

$response = mysql_query("select * from inmi_foto", $db);
while($row = mysql_fetch_array($response))
{...}

is located on the HTML code.

To try I replaced the function

function mouseover()
{
document.getElementById("mytd").innerHTML="<img src=\"<? $row["thumb"] ?>\">";
}

for

function mouseover()
{
document.getElementById("mytd").innerHTML="<img src=\"../images/derqui.jpg\">";
}


and works fine. The problem seems to be the access to the DB images.

The page is located at http://www.historiadelpais.com.ar/inmi1.php?id=2

Thanks!

pyro
02-25-2003, 09:45 PM
I don't think I understand what you are asking. Come again?

esapo
02-25-2003, 09:58 PM
The problem is that if I use the complete name of an image in the function, it works fine, but if I want to use a query on a DB, the code does not work. So, I want to know if I have to declare the query on the JV function (Connect to DB, do the query, etc).

Thanks,

pyro
02-25-2003, 10:09 PM
Still not totally sure what you are asking, but I think that the answer is "yes", you will need to query the database. How else is it going to know which image it is that you are after?