1 <% include('/elements/xmlhttp.html',
2 'url' => $p.'misc/areacodes.cgi',
3 'subs' => [ $opt{'prefix'}. 'get_areacodes' ],
7 <SCRIPT TYPE="text/javascript">
9 function jopt(what,value,text) {
10 var optionName = new Option(text, value, false, false);
11 what.append(optionName);
14 function <% $opt{'state_prefix'} %>state_changed(what, callback) {
16 what.form.<% $opt{'prefix'} %>areacode.disabled = 'disabled';
17 what.form.<% $opt{'prefix'} %>areacode.style.display = 'none';
18 var areacodewait = document.getElementById('<% $opt{'prefix'} %>areacodewait');
19 areacodewait.style.display = 'inline';
20 var areacodeerror = document.getElementById('<% $opt{'prefix'} %>areacodeerror');
21 areacodeerror.style.display = 'none';
23 what.form.<% $opt{'prefix'} %>exchange.disabled = 'disabled';
24 $('#<% $opt{'prefix'} %>phonenum').prop('disabled', true);
26 var state = what.options[what.selectedIndex].value;
28 function <% $opt{'prefix'} %>update_areacodes(areacodes) {
30 var reply = JSON.parse(areacodes);
31 // blank the current areacode
32 $('#<% $opt{prefix} %>areacode').empty();
34 // blank the current exchange too
35 $('#<% $opt{prefix} %>exchange').empty();
36 jopt( $('#<% $opt{prefix} %>exchange'), '', 'Select city / exchange' );
38 // blank the current phonenum too
39 $('#<% $opt{prefix} %>phonenum').empty();
40 if ( what.form.<% $opt{'prefix'} %>phonenum.type != 'select-multiple' ) {
41 jopt($('#<% $opt{'prefix'} %>phonenum'), '', 'Select phone number');
45 jopt($('#<% $opt{'prefix'} %>areacode'), '', '<% $opt{empty} %>');
48 // add the new areacodes
49 var areacodeArray = reply.areacodes;
50 for ( var s = 0; s < areacodeArray.length; s++ ) {
51 var areacodeLabel = areacodeArray[s];
52 if ( areacodeLabel == "" )
53 areacodeLabel = '(n/a)';
54 jopt($('#<% $opt{'prefix'} %>areacode'), areacodeArray[s], areacodeLabel);
57 areacodewait.style.display = 'none';
58 if ( areacodeArray.length >= 1 ) {
59 what.form.<% $opt{'prefix'} %>areacode.disabled = '';
60 what.form.<% $opt{'prefix'} %>areacode.style.display = '';
62 var areacodeerror = document.getElementById('<% $opt{'prefix'} %>areacodeerror');
63 areacodeerror.style.display = 'inline';
65 areacodeerror.textContent = reply.error;
67 areacodeerror.textContent = 'Select a different state';
72 if ( callback != null )
76 // go get the new areacodes
77 <% $opt{'prefix'} %>get_areacodes( state, <% $opt{'svcpart'} %>, <% $opt{'prefix'} %>update_areacodes );
83 <DIV ID="areacodewait" STYLE="display:none"><IMG SRC="<%$fsurl%>images/wait-orange.gif"> <B>Finding area codes</B></DIV>
85 <DIV ID="areacodeerror" STYLE="display:none; font-weight: bold"><IMG SRC="<%$fsurl%>images/cross.png"></DIV>
88 ID = "<% $opt{prefix} %>areacode"
89 NAME = "<% $opt{prefix} %>areacode"
90 onChange = "<% $opt{prefix} %>areacode_changed(this); <% $opt{onchange} %>"
93 <OPTION VALUE="">Select area code</OPTION>
100 $opt{disabled} = 'disabled' unless exists $opt{disabled};
101 $opt{state_prefix} = $opt{prefix} unless exists $opt{state_prefix};