if(getpobox && getposub && getpopcode && getstate2){
I'm assuming you mean getstate1?
Whenever you find yourself repeating code, it's a sure sign that you should be using a loop. Put them into an array first, then we can use some basic list-processing functions (map and filter) on them:
Code:
Array.prototype.map = function(f) {
for(var i = 0, r = [], n = this.length; i < n; ++i)
r.push(f(this[i], i));
return r;
};
Array.prototype.filter = function(f) {
if(!f)
f = function(v) { return !!v; };
for(var i = 0, r = [], n = this.length; i < n; ++i)
if(f(this[i], r))
r.push(this[i]);
return r;
};
rs("po_address").value = ["postal_address", "postal_suburb", "postal_code", "state"].map(
function(v) {
return rs("std_" + v).value;
}).filter().join(" ") + " ";
Bookmarks