Link to home
Start Free TrialLog in
Avatar of andyrr1
andyrr1

asked on

unterminated string constant javascript error and line wrapping in html

Hi,

I have a problem with some javascript - I have some PHP which prints out a number of links with an onMouseOver event as below.....where for some records, the description seems to start on a new line and generates an unterminated string constant error.

Is there any way of managing where the source wraps - I've tried putting \n charachters part way through the description but the "As systems accountant" bit always seems to start on the next line.  I'm pretty sure that text doesn't have any strange starting characters.

HTML source produced

<a class="article_link" alt="Click to view or edit" href="editarticle.php?type=9&id=61" onMouseOut="HideHelp('desc61');" onMouseOver="ShowHelp('desc61', '','
As Systems Accountant you will be responsible for developing this legal firm&#8217;s primary reporting system and implementing other accounting syst...');">
SYSTEMS ACCOUNTANT</a>



The PHP code if it helps is.....

                 $text = substr(strip_tags($desc_query_data[$query_data["fieldname"]]), 0, 150);
                 $text = str_replace("'", "", $text);
                  print "   <td valign=\"top\" class=\"".$row_type."\">\n<a class=\"article_link\"\n alt=\"Click to view or edit\" href=\"editarticle.php?type=".$type."&id=".$rec_id."\" onMouseOut=\"HideHelp('desc".$rec_id."');\"\n onMouseOver=\"ShowHelp('desc".$rec_id."', '','".$text."...');\">\n".$field_values[$fields_to_display[$counter]]."</a><div style=\"display:none\" id=\"desc".$rec_id."\"></div></td>\n";
Avatar of hielo
hielo
Flag of Wallis and Futuna image

try:
                 $text = substr(strip_tags($desc_query_data[$query_data["fieldname"]]), 0, 150);
                 $text = str_replace("'", "", $text);
			  $text = str_replace("\n","\\n",$text);
                  print "   <td valign=\"top\" class=\"".$row_type."\">\n<a class=\"article_link\"\n alt=\"Click to view or edit\" href=\"editarticle.php?type=".$type."&id=".$rec_id."\" onMouseOut=\"HideHelp('desc".$rec_id."');\"\n onMouseOver=\"ShowHelp('desc".$rec_id."', '','".$text."...');\">\n".$field_values[$fields_to_display[$counter]]."</a><div style=\"display:none\" id=\"desc".$rec_id."\"></div></td>\n";

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ncoo
ncoo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial