By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,149 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

javascript error in php string concatination

omerbutt
100+
P: 638
hi there i have a page on which i am trying to call the tooltips on the images , the images info is comming from database so i have to use php to echo them and have to concatinate the javascript function that is called onMouseover this function takes
3 parameters
1.event,2.comments,3.true
in the comments part when i simply pass the text it works perfect but when i have to pass the Comments along the <a> tag andimg img tag it gives me eror, here is the error code and the source code
missing ) after argument list
[Break on this error] showHelpTip(event,'<a><img src='images/x_icon.gif' /></a>', true); return false;
echo "<td align=\"left\" valign=\"top\" width=\"82\">
<div id=\"$addons[$ad]_div\">
<img id=\"$addons[$ad]\" name=\"off\" src=\"images/$addons[$ad]_off.gif\" width=\"82\" height=\"93\" border=\"0\" alt=\"\" onMouseOver=\"showHelpTip(event,'<a><img src='images/x_icon.gif' /></a>', true); return false;\" onclick=\"AddOnFor(this.id,0,$adonprc)\" style=\"cursor:pointer;\" />
</div></td>";
Sep 3 '08 #1
Share this Question
Share on Google+
2 Replies


nathj
Expert 100+
P: 938
Hi,

Maybe I'm missing the point a bit here but why can't you use the 'title' attribute? this could then take the information you have in the database. the info would display on mouseOver, be helpful to screen readers and save on the use of JavaScript.

Most browsers will display a large amount of data, if that's not enough or you want more formatting may I suggest a combination of what I'm saying - using the title attribute for a summary of the information and then a small ? icon that when clicked loads either a new page/div with the full details or display the info using something like thickbox.

That's how I would approach the problem. I know I haven't answered the question directly but the code you posted was hard to read as you did not use code tags.

If you post back with code tags I may be able to spot if there is a problem in the string concatenation - there's normally a quote mark that's not escaped or not closed.

Cheers
nathj
Sep 3 '08 #2

nathj
Expert 100+
P: 938
hi there i have a page on which i am trying to call the tooltips on the images , the images info is comming from database so i have to use php to echo them and have to concatinate the javascript function that is called onMouseover this function takes
3 parameters
1.event,2.comments,3.true
in the comments part when i simply pass the text it works perfect but when i have to pass the Comments along the <a> tag andimg img tag it gives me eror, here is the error code and the source code


echo "<td align=\"left\" valign=\"top\" width=\"82\">
<div id=\"$addons[$ad]_div\">
<img id=\"$addons[$ad]\" name=\"off\" src=\"images/$addons[$ad]_off.gif\" width=\"82\" height=\"93\" border=\"0\" alt=\"\" onMouseOver=\"showHelpTip(event,'<a><img src='images/x_icon.gif' /></a>', true); return false;\" onclick=\"AddOnFor(this.id,0,$adonprc)\" style=\"cursor:pointer;\" />
</div></td>";
further to my previous response please accept my apologies for being so short. I'm having my loft converted starting today and the noise is awful!

I've looked more closely at your code and this is what I suggest:
[PHP]
$lcDisplay = '<td align="left" valign="top" width="82">' ;
$lcDisplay .= '<div id=" ' . $addons[$ad] . '_div"> ';
$lcDisplay .= '<img id="' .$addons[$ad] .'" name="off" src="images/' . $addons[$ad] . '_off.gif" width="82" height="93" border="0" alt="PUT SOMETHING HERE"
onMouseOver="showHelpTip(event,\'<a><img src=images/x_icon.gif\' /></a>\', true); return false;"
onclick="AddOnFor(this.id,0, \'' . $adonprc .'\')" style="cursor:pointer;" /> ';
$lcDisplay .= '</div></td>' ;

echo $lcDisplay
[/PHP]

Depending on what $adonproc is you may or may not need the quotes I've added around it.

Sorry again about the first post, I hope this is more helpful.

Cheers
nathj
Sep 3 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.