X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Felements%2Fselect-county.html;h=cce085f12aa630193fb0582f5d4c9b281096d534;hp=8ef34dbe60f538d2b588d11cf56a71f06aab2849;hb=7b0bbc4117a7959b9f7b7b2cf999b8188ba34160;hpb=d8cb6cd67cc574c90dbbfbd8db2da6711c516d65 diff --git a/httemplate/elements/select-county.html b/httemplate/elements/select-county.html index 8ef34dbe6..cce085f12 100644 --- a/httemplate/elements/select-county.html +++ b/httemplate/elements/select-county.html @@ -2,7 +2,7 @@ Example: - include( '/elements/select-county.html', + <& /elements/select-county.html, #recommended country => $current_country, state => $current_state, @@ -12,9 +12,10 @@ Example: prefix => $optional_unique_prefix, onchange => $javascript, disabled => 0, #bool - disable_empty => 1, #defaults to 1, disable the empty option + disable_empty => 1, #defaults to 1, set to 0 to disable the empty option empty_label => 'all', #label for empty option - ); + style => [ 'attribute:value', 'another:value' ], + &> % if ( $countyflag ) { @@ -35,6 +36,8 @@ Example: function <% $pre %>state_changed(what, callback) { + what.form.<% $pre %>county.disabled = 'disabled'; + state = what.options[what.selectedIndex].value; country = what.form.<% $pre %>country.options[what.form.<% $pre %>country.selectedIndex].value; @@ -43,6 +46,10 @@ Example: // blank the current county list for ( var i = what.form.<% $pre %>county.length; i >= 0; i-- ) what.form.<% $pre %>county.options[i] = null; + +% unless ( $opt{disable_empty} ) { + opt( what.form.<% $pre %>county, '', <% $opt{empty_label} |js_string %> ); +% } // add the new counties var countiesArray = eval('(' + counties + ')' ); @@ -57,15 +64,26 @@ Example: if ( countiesArray.length > 1 ) { what.form.<% $pre %>county.style.display = ''; - countyFormLabel.style.visibility = 'visible'; + if ( countyFormLabel ) { + //countyFormLabel.style.visibility = 'visible'; + countyFormLabel.style.display = ''; + } } else { what.form.<% $pre %>county.style.display = 'none'; - countyFormLabel.style.visibility = 'hidden'; + if ( countyFormLabel ) { + //countyFormLabel.style.visibility = 'hidden'; + countyFormLabel.style.display = 'none'; + } } + what.form.<% $pre %>county.disabled = ''; + //run the callback - if ( callback != null ) + if ( callback != null ) { callback(); + } else { + <% $pre %>county_changed(what.form.<% $pre %>county); + } } // go get the new counties @@ -77,8 +95,9 @@ Example: