1 <% include('/elements/xmlhttp.html',
2 'url' => $p.'misc/regions.cgi',
3 'subs' => [ $opt{'prefix'}. 'get_regions' ],
7 <SCRIPT TYPE="text/javascript">
9 function opt(what,value,text) {
10 var optionName = new Option(text, value, false, false);
11 var length = what.length;
12 what.options[length] = optionName;
15 function <% $opt{'state_prefix'} %>state_changed(what, callback) {
17 what.form.<% $opt{'prefix'} %>region.disabled = 'disabled';
18 what.form.<% $opt{'prefix'} %>region.style.display = 'none';
19 var regionwait = document.getElementById('<% $opt{'prefix'} %>regionwait');
20 regionwait.style.display = 'inline';
21 var regionerror = document.getElementById('<% $opt{'prefix'} %>regionerror');
22 regionerror.style.display = 'none';
24 what.form.<% $opt{'prefix'} %>phonenum.disabled = 'disabled';
26 state = what.options[what.selectedIndex].value;
28 function <% $opt{'prefix'} %>update_regions(regions) {
30 // blank the current region
31 for ( var i = what.form.<% $opt{'prefix'} %>region.length; i >= 0; i-- )
32 what.form.<% $opt{'prefix'} %>region.options[i] = null;
33 // blank the current phonenum too
34 for ( var i = what.form.<% $opt{'prefix'} %>phonenum.length; i >= 0; i-- )
35 what.form.<% $opt{'prefix'} %>phonenum.options[i] = null;
36 if ( what.form.<% $opt{'prefix'} %>phonenum.type != 'select-multiple' ) {
37 opt(what.form.<% $opt{'prefix'} %>phonenum, '', 'Select phone number');
41 opt(what.form.<% $opt{'prefix'} %>region, '', '<% $opt{empty} %>');
44 // add the new regions
45 var regionArray = eval('(' + regions + ')' );
46 for ( var s = 0; s < regionArray.length; s++ ) {
47 var regionLabel = regionArray[s];
48 if ( regionLabel == "" )
49 regionLabel = '(n/a)';
50 opt(what.form.<% $opt{'prefix'} %>region, regionArray[s], regionLabel);
53 regionwait.style.display = 'none';
54 if ( regionArray.length >= 1 ) {
55 what.form.<% $opt{'prefix'} %>region.disabled = '';
56 what.form.<% $opt{'prefix'} %>region.style.display = '';
58 var regionerror = document.getElementById('<% $opt{'prefix'} %>regionerror');
59 regionerror.style.display = 'inline';
63 if ( callback != null )
67 // go get the new regions
68 <% $opt{'prefix'} %>get_regions( state, <% $opt{'svcpart'} %>, <% $opt{'prefix'} %>update_regions );
74 <DIV ID="<% $opt{'prefix'} %>regionwait" STYLE="display:none"><IMG SRC="<%$fsurl%>images/wait-orange.gif"> <B>Finding regions</B></DIV>
76 <DIV ID="<% $opt{'prefix'} %>regionerror" STYLE="display:none"><IMG SRC="<%$fsurl%>images/cross.png"> <B>Select a different state</B></DIV>
78 <SELECT NAME="<% $opt{'prefix'} %>region" onChange="<% $opt{'prefix'} %>region_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
79 <OPTION VALUE="">Select region</OPTION>
86 $opt{disabled} = 'disabled' unless exists $opt{disabled};