1 <% include('/elements/xmlhttp.html',
2 'url' => $p.'misc/areacodes.cgi',
3 'subs' => [ $opt{'prefix'}. 'get_areacodes' ],
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'} %>areacode.disabled = 'disabled';
18 what.form.<% $opt{'prefix'} %>areacode.style.display = 'none';
19 var areacodewait = document.getElementById('<% $opt{'prefix'} %>areacodewait');
20 areacodewait.style.display = 'inline';
21 var areacodeerror = document.getElementById('<% $opt{'prefix'} %>areacodeerror');
22 areacodeerror.style.display = 'none';
24 what.form.<% $opt{'prefix'} %>exchange.disabled = 'disabled';
25 what.form.<% $opt{'prefix'} %>phonenum.disabled = 'disabled';
27 var state = what.options[what.selectedIndex].value;
29 function <% $opt{'prefix'} %>update_areacodes(areacodes) {
31 // blank the current areacode
32 for ( var i = what.form.<% $opt{'prefix'} %>areacode.length; i >= 0; i-- )
33 what.form.<% $opt{'prefix'} %>areacode.options[i] = null;
34 // blank the current exchange too
35 for ( var i = what.form.<% $opt{'prefix'} %>exchange.length; i >= 0; i-- )
36 what.form.<% $opt{'prefix'} %>exchange.options[i] = null;
37 opt(what.form.<% $opt{'prefix'} %>exchange, '', 'Select city / exchange');
38 // blank the current phonenum too
39 for ( var i = what.form.<% $opt{'prefix'} %>phonenum.length; i >= 0; i-- )
40 what.form.<% $opt{'prefix'} %>phonenum.options[i] = null;
41 if ( what.form.<% $opt{'prefix'} %>phonenum.type != 'select-multiple' ) {
42 opt(what.form.<% $opt{'prefix'} %>phonenum, '', 'Select phone number');
46 opt(what.form.<% $opt{'prefix'} %>areacode, '', '<% $opt{empty} %>');
49 // add the new areacodes
50 var areacodeArray = eval('(' + areacodes + ')' );
51 for ( var s = 0; s < areacodeArray.length; s++ ) {
52 var areacodeLabel = areacodeArray[s];
53 if ( areacodeLabel == "" )
54 areacodeLabel = '(n/a)';
55 opt(what.form.<% $opt{'prefix'} %>areacode, areacodeArray[s], areacodeLabel);
58 areacodewait.style.display = 'none';
59 if ( areacodeArray.length >= 1 ) {
60 what.form.<% $opt{'prefix'} %>areacode.disabled = '';
61 what.form.<% $opt{'prefix'} %>areacode.style.display = '';
63 var areacodeerror = document.getElementById('<% $opt{'prefix'} %>areacodeerror');
64 areacodeerror.style.display = 'inline';
68 if ( callback != null )
72 // go get the new areacodes
73 <% $opt{'prefix'} %>get_areacodes( state, <% $opt{'svcpart'} %>, <% $opt{'prefix'} %>update_areacodes );
79 <DIV ID="areacodewait" STYLE="display:none"><IMG SRC="<%$fsurl%>images/wait-orange.gif"> <B>Finding area codes</B></DIV>
81 <DIV ID="areacodeerror" STYLE="display:none"><IMG SRC="<%$fsurl%>images/cross.png"> <B>Select a different state</B></DIV>
83 <SELECT NAME="<% $opt{'prefix'} %>areacode" onChange="<% $opt{'prefix'} %>areacode_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
84 <OPTION VALUE="">Select area code</OPTION>
91 $opt{disabled} = 'disabled' unless exists $opt{disabled};
92 $opt{state_prefix} = $opt{prefix} unless exists $opt{state_prefix};