Hi,

I'm using a tooltip with the help of javascript. And when user places his / her cursor over the variable, $names[mname], it shows other dynamic values in the tooltip.

However, i found out that it only works for static values....how can i overcome this so that it can show the value of $names[mname] ?

This works (static value):

echo'<div onMouseover="ddrivetip(\' Display message here\')" onMouseout="hideddrivetip()">Move your mouse over</div>';

But not this (dynamic):

echo'<div onMouseover="ddrivetip(\' $names[atk] \')" onMouseout="hideddrivetip()">$names[mname]:</div>';

Any help / comment will be appreciated. Thank you.

    Variables aren't interpolated inside single-quoted strings.
    Try

    echo '<div onMouseover="ddrivetip(\' '.$names[atk].' \')" onMouseout="hideddrivetip()">'.$names[mname].':</div>';
    

    Or even just

    <div onMouseover="ddrivetip(' '<?php echo $names['atk']?>')" onMouseout="hideddrivetip()"><?php echo $names['mname']?>:</div>
    

      Thanks, Weedpacket

      Now its working perfectly. 😃

        Write a Reply...