• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 753
  • Last Modified:

Line break in javascript alert using xajax

How would you encode this variable to include line breaks? I have tried <br>, \n, \r\n it hanges up with all of them.

$myhtml = " Count: ". $row . " Taxid: ". $taxid . "\r\n Legal: " . $sub . " " . $blk . " " . $lot . " \r\nOwner: ".$fname . " " . $lname;

$objResponse->script("alert(myhtml = '$myhtml';")

Thanks.
0
ALASKASTREETMASTER
Asked:
ALASKASTREETMASTER
  • 5
  • 4
1 Solution
 
Roger BaklundCommented:
You must double the backslashes, and the alert call is wrong:

$myhtml = " Count: ". $row . " Taxid: ". $taxid . "\\r\\n Legal: " . $sub . " " . $blk . " " . $lot . " \\r\\nOwner: ".$fname . " " . $lname;

$objResponse->script("alert('$myhtml');")
0
 
ALASKASTREETMASTERAuthor Commented:
Did not work still no line breakes.  I add another one since google is using it to in the marker popup.
That did not work either.  Any other ideas?

$myhtml = " Count: ". $row . " Taxid: ". $taxid . "\\\r\\\n Legal: " . $sub . " " . $blk . " " . $lot . " \\\r\\\nOwner: ".$fname . " " . $lname;

0
 
Roger BaklundCommented:
Two backslashes works for me. What kind of values are in the other variables? You can not have linefeeds or apostrophes.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
ALASKASTREETMASTERAuthor Commented:
I am trying to do an alert to see if the alert has line breaks. missing some thing on quatoes.
$objResponse->script("row=$row;taxid = $taxid;alert('myhtml=\'$myhtml\';taxid = $taxid'');");
0
 
Roger BaklundCommented:
You have a syntax error in your alert() call. Correct syntax is:

  alert(strParam)

So in the PHP string above, it should be:

$objResponse->script("row=$row;taxid = $taxid;alert('$myhtml');");
0
 
ALASKASTREETMASTERAuthor Commented:
works in the alert.  but not in the google marker popup using the same vairable.
I could live with the alert instead of the google marker except that I need to put links in the popup to get additional information if the user chooses. Can that be done in a alert?
0
 
Roger BaklundCommented:
No, the javascript alert can not have links, just plain text.

I think the google marker popup is html-based, so \n will not work there, but <br /> should work.
0
 
ALASKASTREETMASTERAuthor Commented:
that did it.  thank you! This stuff is comming together, but slowly.  php,xaxjax, javascript, html,filemaker. A lot to learn all at once. I think my biggest problem is mixing syntax between platforms.
0
 
ALASKASTREETMASTERAuthor Commented:
thanks again.  I appreciate your quick responses.  
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now