X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Ftr-select-cust_location.html;h=4c17249bda53964739c70fc8df616ae57f5a20b1;hb=a59da6000c99b8fa3f391122900c44735593f544;hp=d9e3e9e27a3bc164760bb9af6da09915f9d2469b;hpb=f3c4966ed1f6ec3db7accd6dcdd3a5a3821d72a7;p=freeside.git diff --git a/httemplate/elements/tr-select-cust_location.html b/httemplate/elements/tr-select-cust_location.html index d9e3e9e27..4c17249bd 100644 --- a/httemplate/elements/tr-select-cust_location.html +++ b/httemplate/elements/tr-select-cust_location.html @@ -52,10 +52,11 @@ Example: if( ftype != 'SELECT') what.form.<%$_%>.style.backgroundColor = '#ffffff'; % } % if ( $opt{'alt_format'} ) { - if ( what.form.location_type.options[what.form.location_type.selectedIndex].value ) { + if ( what.form.location_type && + what.form.location_type.options[what.form.location_type.selectedIndex].value ) { what.form.location_number.disabled = false; what.form.location_number.style.backgroundColor = '#ffffff'; - } + } % } } @@ -152,25 +153,16 @@ Example: } } + var location_fields = <% to_json(\@location_fields) %>; function update_location( string ) { - var hash = eval('('+string+')'); - document.getElementById('address1').value = hash['address1']; - document.getElementById('city').value = hash['city']; - document.getElementById('zip').value = hash['zip']; - -% if ( $opt{'alt_format'} ) { - changeSelect( document.getElementById('location_kind'), hash['location_kind']); - changeSelect( document.getElementById('location_type'), hash['location_type']); - document.getElementById('location_number').value = hash['location_number']; -% } else { - document.getElementById('address2').value = hash['address2']; -% } - - var country_el = document.getElementById('country'); - - changeSelect( country_el, hash['country'] ); - - country_changed( country_el, + var hash = JSON.parse(string); + for(var i = 0; i < location_fields.length; i++) { + var f = location_fields[i]; + if (hash[f] && document.getElementById(f)) { + document.getElementById(f).value = hash[f]; + } + } + country_changed( document.getElementById('country'), fix_state_factory( hash['state'], hash['county'] ) @@ -184,7 +176,7 @@ Example: