I need to display an address dynamically from the database, but I don’t want blank lines if address2 is blank in the record.
I’m using tags in a text property to compile the fields into an address label and I can easily display the address, but is there a way, perhaps with javascript inside the html, to check each field and only append it if it is not blank?
Thanks for any hints.
I’m not sure I exactly understand the question, but I typically have a two calculations on any table that contains an address, that concatenate and formatted version in text and html. The text one would look something like:
var s = '';
s += address1 ? address1 + "\n" : '';
s += address2 ? address2 + "\n" : '';
s += city ? city + ", " : '';
s += state ? state + " " : '';
s += zip ? zip : '';
return s;
So, it only adds the fields that have a value. Is that what you are wanting?
greg.
Thanks Greg. You’re on the right track and your solution is probably what I’ll go with.
My question was, can I run javascript from within a text property on a form label. I was trying to solve the same problem you addressed, but without having a calc field.
I’d still be curious to know if javascript will run within the html in a text property though. Anyone tried it?
No, you can evaluate javascript inside a text label.
You can, however, name the label so it’s a form element, and manipulated it’s value from methods.
greg.