1 <% include('/elements/xmlhttp.html',
2 'url' => $p.'misc/exchanges.cgi',
3 'subs' => [ $opt{'prefix'}. 'get_exchanges' ],
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{'prefix'} %>areacode_changed(what, callback) {
16 what.form.<% $opt{'prefix'} %>exchange.disabled = 'disabled';
17 what.form.<% $opt{'prefix'} %>exchange.style.display = 'none';
18 var exchangewait = document.getElementById('<% $opt{'prefix'} %>exchangewait');
19 exchangewait.style.display = 'inline';
20 var exchangeerror = document.getElementById('<% $opt{'prefix'} %>exchangeerror');
21 exchangeerror.style.display = 'none';
23 $('#<% $opt{'prefix'} %>phonenum').prop('disabled', true);
25 areacode = what.options[what.selectedIndex].value;
27 function <% $opt{'prefix'} %>update_exchanges(exchanges) {
29 var reply = JSON.parse(exchanges);
30 // blank the current exchange
31 $('#<% $opt{prefix} %>exchange').empty();
33 // blank the current phonenum too
34 $('#<% $opt{prefix} %>phonenum').empty();
35 if ( what.form.<% $opt{'prefix'} %>phonenum.type != 'select-multiple' ) {
36 jopt($('#<% $opt{'prefix'} %>phonenum'), '', 'Select phone number');
40 jopt($('#<% $opt{'prefix'} %>exchange'), '', '<% $opt{empty} %>');
43 // add the new exchanges
44 var exchangeArray = reply.exchanges;
45 for ( var s = 0; s < exchangeArray.length; s++ ) {
46 var exchangeLabel = exchangeArray[s];
47 if ( exchangeLabel == "" )
48 exchangeLabel = '(n/a)';
49 jopt($('#<% $opt{'prefix'} %>exchange'), exchangeArray[s], exchangeLabel);
52 exchangewait.style.display = 'none';
53 if ( exchangeArray.length >= 1 ) {
54 what.form.<% $opt{'prefix'} %>exchange.disabled = '';
55 what.form.<% $opt{'prefix'} %>exchange.style.display = '';
57 var exchangeerror = document.getElementById('<% $opt{'prefix'} %>exchangeerror');
58 exchangeerror.style.display = 'inline';
60 exchangeerror.textContent = reply.error;
62 exchangeerror.textContent = 'Select a different area code';
68 if ( callback != null )
72 // go get the new exchanges
73 <% $opt{'prefix'} %>get_exchanges( areacode, <% $opt{'svcpart'} %>, <% $opt{'prefix'} %>update_exchanges );
79 <DIV ID="exchangewait" STYLE="display:none"><IMG SRC="<%$fsurl%>images/wait-orange.gif"> <B>Finding cities / exchanges</B></DIV>
81 <DIV ID="exchangeerror" STYLE="display:none; font-weight: bold"><IMG SRC="<%$fsurl%>images/cross.png"></DIV>
84 ID = "<% $opt{prefix} %>exchange"
85 NAME = "<% $opt{prefix} %>exchange"
86 onChange = "<% $opt{prefix} %>exchange_changed(this); <% $opt{onchange} %>"
89 <OPTION VALUE="">Select city / exchange</OPTION>
96 $opt{disabled} = 'disabled' unless exists $opt{disabled};