Page 1 of 1

Extra space added in while putting string into a Label.

Posted: Sun Jan 25, 2015 5:26 am
by Patrick Kelly

I am using Javascript to take the value of three Labels and put them into one Label. It works, but I am getting an extra space that looks terrible.

Here is my code:

var city = Appery("City").text();
var state = Appery("State").text();
var zip = Appery("Zip").text();
Appery("CityStateZip").text(city + ", " + state + " " + zip);

My output should be "City, State Zip". Instead, it is "City , State Zip". I've checked, there is no space in the original text field of the label. If I use an input instead, there's no problem, only if I am retrieving the data from a label. Any idea as to why?


Extra space added in while putting string into a Label.

Posted: Sun Jan 25, 2015 5:33 am
by M&M

not sure how that space creeps in, but there a fix (workaround?)....you can just do this and see the result

Appery("CityStateZip").text(city.trim() + ", " + state + " " + zip);


Extra space added in while putting string into a Label.

Posted: Sun Jan 25, 2015 5:59 am
by Patrick Kelly

Thanks, that works!