2

Using this StackOverflow Question/Answer, I have a Tooltip Javascript that is supposed to use a PHP echo of a session variable. Instead of actually writing out the value, it is writing out the variable name, myvar?

I tried to \ the echo statement where ' occur with no luck.

Here is the code in question and screenshot of what I'm getting on mouseover:

var ddimgtooltip={

    tiparray:function(){
        var tooltips=[]
        var myvar='<?php echo($row_WADAHTG_ScheduleRequest[\'EmNo\']); ?>';
        tooltips[0]=["image/emp/$myvar.bmp", "$myvar", {background:"#DDECFF", width:"200px"}]
        return tooltips //do not remove/change this line
    }(),

enter image description here

3

2 Answers 2

3

try tho change this:

var myvar='<?php echo($row_WADAHTG_ScheduleRequest[\'EmNo\']); ?>';
tooltips[0]=["image/emp/$myvar.bmp", "$myvar", {background:"#DDECFF", width:"200px"}]

to this:

var myvar='<?php echo($row_WADAHTG_ScheduleRequest[\'EmNo\']); ?>';
tooltips[0]=["image/emp/" + myvar + ".bmp", myvar, {background:"#DDECFF", width:"200px"}]

you have already your php value into myvar so you don't need to use $myvar as in php but only myvar for javascript

Sign up to request clarification or add additional context in comments.

1 Comment

yep... he is mixing php and js
1

try:

var myvar='<?php echo($row_WADAHTG_ScheduleRequest[\'EmNo\']); ?>';
tooltips[0]=["image/emp/" + myvar + ".bmp", myvar, {background:"#DDECFF", width:"200px"}]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.