What you do to pass from php to js is right, but what are you trying to do ?
There is no document.name property, and that's your error....
You are passing a "name" variable to your function, so reference it.
Your problem is to find the reference to the image.
For that, I either recommand you to put an id rather than a name on the image, and to use documnet.getElementById('the_id'); to find it back
Code:
function highlight(_id){
var trg=document.getElementById(_id);
trg.src ="\images\rating\star2.gif";
}
<img src="\images\rating\star1.gif" onmouseover="highlight('<?php echo $count; ?>')" id="<?php echo $count; ?>">
Or to put a reference on the image directly on the function call:
Code:
function highlight(trg){
trg.src ="\images\rating\star2.gif";
}
<img src="\images\rating\star1.gif" onmouseover="highlight(this)" id="<?php echo $count; ?>">
Here, this reference to img from whose the onmouseover event trigerred, so no need to search it again.
I personally prefer to use this syntax, rather than to search for an id.
Extend the call to include every variables that you might need:
Code:
function highlight(_value, _elm){
_elm.src ="\images\rating\"+_value+".gif";
}
<img src="\images\rating\star1.gif" onmouseover="highlight('<?php echo $count; ?>', this)" id="<?php echo $count; ?>">
__________________
Listen to the ducky: "This is awesome!!!"
|