Solved

Line break in javascript alert using xajax

Posted on 2009-04-09
9
710 Views
Last Modified: 2013-12-13
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
Comment
Question by:ALASKASTREETMASTER
  • 5
  • 4
9 Comments
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24112402
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
 

Author Comment

by:ALASKASTREETMASTER
ID: 24112443
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
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24112457
Two backslashes works for me. What kind of values are in the other variables? You can not have linefeeds or apostrophes.
0
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 

Author Comment

by:ALASKASTREETMASTER
ID: 24112530
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
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24112565
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
 

Author Comment

by:ALASKASTREETMASTER
ID: 24112587
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
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 500 total points
ID: 24112679
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
 

Author Comment

by:ALASKASTREETMASTER
ID: 24112793
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
 

Author Closing Comment

by:ALASKASTREETMASTER
ID: 31568773
thanks again.  I appreciate your quick responses.  
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP populating an array. 4 25
google map tracking website 5 24
PHP curl issue VERBOSE output 18 44
does post require a form or curl to be post 4 33
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question