OL Learn

Space not retain from Data to HTML

Hi,
I am ran into an issue where the space in the data point (data string) is not retain in the html.

I have try the following code. Try to do a replace but getting the error of "missing (after argument list). Please advise any other alternative work around to retain the space?

mailtoBK = f.BKAtty;
if (f.BKAtty == “”) { mailtoBK += f.BKATTYOFFICE; }
mailtoBK += ‘
’ + f.BKAttyAddress1;
if (f.BKAttyAddress2 !== “”) { mailtoBK += ‘
’ + f.BKAttyAddress2; }
mailtoBK += ‘
’ + ZipCode(f.BKAttyCitySTZip.replace(//g, ‘\u00a00’));
query("#mailtoAddr").html(mailtoBK);

When you say “space”, do you mean you are trying to insert a new line character in between each part of the address?
If that’s the case, then you could use something like this:

var mailtoBK="";
mailtoBK += (f.BKAtty) ? f.BKATTYOFFICE+"\n" : f.BKAtty+"\n";
mailtoBK += f.BKAttyAddress1+"\n";
mailtoBK += (f.BKAttyAddress2) ? f.BKAttyAddress2+"\n" : "";
mailtoBK += ZipCode(f.BKAttyCitySTZip.replace(//g, "\u00a00"));

Note that I don’t know what your ZipCode method does, but the replace() expression looks wrong to me since you’re not specifying anything to search for.

space in this case mean that I want it to pass the extract how what file data point look like to html.

data point look like this: |“Fremont, CA 94536”|
html and designer view: image
Want to accomplish: image

As Phil mentioned, the problem lies in your REGEX. Add \s in it and it should work.

mailtoBK += ‘
’ + ZipCode(f.BKAttyCitySTZip.replace(/\s/g, ‘\u00a00’));
query("#mailtoAddr").html(mailtoBK);

1 Like