1 <% include('/elements/xmlhttp.html',
2 'url' => $p.'misc/exchanges.cgi',
3 'subs' => [ $opt{'prefix'}. 'get_exchanges' ],
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{'prefix'} %>areacode_changed(what, callback) {
17 what.form.<% $opt{'prefix'} %>exchange.disabled = 'disabled';
18 what.form.<% $opt{'prefix'} %>exchange.style.display = 'none';
19 var exchangewait = document.getElementById('<% $opt{'prefix'} %>exchangewait');
20 exchangewait.style.display = 'inline';
21 var exchangeerror = document.getElementById('<% $opt{'prefix'} %>exchangeerror');
22 exchangeerror.style.display = 'none';
24 what.form.<% $opt{'prefix'} %>phonenum.disabled = 'disabled';
26 areacode = what.options[what.selectedIndex].value;
28 function <% $opt{'prefix'} %>update_exchanges(exchanges) {
30 var reply = JSON.parse(exchanges);
31 // blank the current exchange
32 for ( var i = what.form.<% $opt{'prefix'} %>exchange.length; i >= 0; i-- )
33 what.form.<% $opt{'prefix'} %>exchange.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'} %>exchange, '', '<% $opt{empty} %>');
45 // add the new exchanges
46 var exchangeArray = reply.exchanges;
47 for ( var s = 0; s < exchangeArray.length; s++ ) {
48 var exchangeLabel = exchangeArray[s];
49 if ( exchangeLabel == "" )
50 exchangeLabel = '(n/a)';
51 opt(what.form.<% $opt{'prefix'} %>exchange, exchangeArray[s], exchangeLabel);
54 exchangewait.style.display = 'none';
55 if ( exchangeArray.length >= 1 ) {
56 what.form.<% $opt{'prefix'} %>exchange.disabled = '';
57 what.form.<% $opt{'prefix'} %>exchange.style.display = '';
59 var exchangeerror = document.getElementById('<% $opt{'prefix'} %>exchangeerror');
60 exchangeerror.style.display = 'inline';
62 exchangeerror.textContent = reply.error;
64 exchangeerror.textContent = 'Select a different area code';
70 if ( callback != null )
74 // go get the new exchanges
75 <% $opt{'prefix'} %>get_exchanges( areacode, <% $opt{'svcpart'} %>, <% $opt{'prefix'} %>update_exchanges );
81 <DIV ID="exchangewait" STYLE="display:none"><IMG SRC="<%$fsurl%>images/wait-orange.gif"> <B>Finding cities / exchanges</B></DIV>
83 <DIV ID="exchangeerror" STYLE="display:none; font-weight: bold"><IMG SRC="<%$fsurl%>images/cross.png"></DIV>
85 <SELECT NAME="<% $opt{'prefix'} %>exchange" onChange="<% $opt{'prefix'} %>exchange_changed(this); <% $opt{'onchange'} %>" <% $opt{'disabled'} %>>
86 <OPTION VALUE="">Select city / exchange</OPTION>
93 $opt{disabled} = 'disabled' unless exists $opt{disabled};