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 var reply = JSON.parse(regions);
31 // blank the current region
32 for ( var i = what.form.<% $opt{'prefix'} %>region.length; i >= 0; i-- )
33 what.form.<% $opt{'prefix'} %>region.options[i] = null;
34 // blank the current phonenum too
35 for ( var i = what.form.<% $opt{'prefix'} %>phonenum.length; i >= 0; i-- )
36 what.form.<% $opt{'prefix'} %>phonenum.options[i] = null;
37 if ( what.form.<% $opt{'prefix'} %>phonenum.type != 'select-multiple' ) {
38 opt(what.form.<% $opt{'prefix'} %>phonenum, '', 'Select phone number');
42 opt(what.form.<% $opt{'prefix'} %>region, '', '<% $opt{empty} %>');
45 // add the new regions
46 var regionArray = reply.regions;
47 for ( var s = 0; s < regionArray.length; s++ ) {
48 var regionLabel = regionArray[s];
49 if ( regionLabel == "" )
50 regionLabel = '(n/a)';
51 opt(what.form.<% $opt{'prefix'} %>region, regionArray[s], regionLabel);
54 regionwait.style.display = 'none';
55 if ( regionArray.length >= 1 ) {
56 what.form.<% $opt{'prefix'} %>region.disabled = '';
57 what.form.<% $opt{'prefix'} %>region.style.display = '';
59 var regionerror = document.getElementById('<% $opt{'prefix'} %>regionerror');
60 regionerror.style.display = 'inline';
62 regionerror.textContent = reply.error;
64 regionerror.textContent = 'Select a different state';
69 if ( callback != null )
73 // go get the new regions
74 <% $opt{'prefix'} %>get_regions( state, <% $opt{'svcpart'} %>, <% $opt{'prefix'} %>update_regions );
80 <DIV ID="<% $opt{'prefix'} %>regionwait" STYLE="display:none"><IMG SRC="<%$fsurl%>images/wait-orange.gif"> <B>Finding regions</B></DIV>
82 <DIV ID="<% $opt{'prefix'} %>regionerror" STYLE="display:none; font-weight: bold"><IMG SRC="<%$fsurl%>images/cross.png"></DIV>
84 <SELECT NAME="<% $opt{'prefix'} %>region" onChange="<% $opt{'prefix'} %>region_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
85 <OPTION VALUE="">Select region</OPTION>
92 $opt{disabled} = 'disabled' unless exists $opt{disabled};