Forums

Javascript won't run from onClick

evanseabrook 30 Sep, 2008
I have a form where the user selects a radio button and selects the province, then they enter the postal code and click submit. It should then output some information. Here is the HTML:
<b>Province:</b><br>
Saskatchewan<INPUT TYPE="radio" NAME="select" id="radio1" VALUE="1" ><br>
Alberta<INPUT TYPE="radio" NAME="select" id="radio2" VALUE="2" ><br>
Manitoba<INPUT TYPE="radio" NAME="select" id="radio3" VALUE="3" ><br>
Postal Code: <input type="text" name="txt1"><br>
<input type="button" value="Submit" onClick="submitForm(this.form)">
<a href="javascript:submitForm(this.form)">Submit</a>
<a href="javascript:reset()">Reset</a><br>


Here is the javascript: (I've condensed the array values)
function submitForm(form) {
var total = document.ChronoContact_Postal_Codes.txt1.value;
var totalsub = total.substr(0,3);
var codesSk=new Array();
var codesMB=new Array();
var codesAB=new Array();
	codesSk[1] = "S7H - Saskatoon - Metro 1";
        codesSk[2] = "S7J - Saskatoon - Metro 1";
        codesSk[3] = "S7K - Saskatoon - Metro 1";
        codesSk[4] = "S7N - Saskatoon - Metro 1";
        codesSk[5] = "S7P - Saskatoon - Metro 1";
        codesSk[6] = "S7S - Saskatoon - Metro 1";
        codesSk[7] = "S7T - Saskatoon - Metro 1";
        codesSk[8] = "S7V - Saskatoon - Metro 1";
        codesSk[9] = "S7W - Saskatoon - Metro 1";
        codesSk[10] = "S4L - Regina - Metro 2";

        codesMB[1] = "R2E - Winnipeg - Metro 1";
        codesMB[2] = "R2J - Winnipeg - Metro 1";
        codesMB[3] = "R2M - Winnipeg - Metro 1";
        codesMB[4] = "R2P - Winnipeg - Metro 1";
        codesMB[5] = "R3J - Winnipeg - Metro 1";
        codesMB[6] = "R3K - Winnipeg - Metro 1";
        codesMB[7] = "R3P - Winnipeg - Metro 1";
        codesMB[8] = "R3R - Winnipeg - Metro 1";
        codesMB[9] = "R3S - Winnipeg - Metro 1";
        codesMB[10] = "R3T - Winnipeg - Metro 1";

        codesAB[1] = "T5A - Edmonton - Metro 1";
        codesAB[2] = "T5C - Edmonton - Metro 1";
        codesAB[3] = "T5K - Edmonton - Metro 1";
        codesAB[4] = "T5N - Edmonton - Metro 1";
        codesAB[5] = "T5R - Edmonton - Metro 1";
        codesAB[6] = "T5S - Edmonton - Metro 1";
        codesAB[7] = "T5T - Edmonton - Metro 1";
        codesAB[8] = "T5X - Edmonton - Metro 1";
        codesAB[9] = "T5Z - Edmonton - Metro 1";
        codesAB[10] = "T6A - Edmonton - Metro 1";

if (document.getElementById('radio1').checked){
	for (var i = 1; i < codesSk.length; i++) 
	{
   		if (totalsub == codesSk[i].substr(0,3)){
			document.write(codesSk[i]);
			document.write("<br />");
 		}
	}

}
else {
	if (document.getElementById('radio2').checked){
		for (var i = 1; i < codesAB.length; i++) 
		{
   			if (totalsub == codesAB[i].substr(0,3)){
				document.write(codesAB[i]);
				document.write("<br />");
 			}
		}
	}
else {
	if (document.getElementById('radio3').checked){
		for (var i = 1; i < codesMB.length; i++) 
		{
   			if (totalsub == codesMB[i].substr(0,3)){
				document.write(codesMB[i]);
				document.write("<br />");
 			}
		}
	}
}
}
}

When I click the Submit button (or link, for that matter), nothing happens. I tried using debug mode but nothing happens then either. Any ideas? Or am I way off base with how ChronoForms works? I should mention that if I put all this in an HTML file, it runs correctly.
Max_admin 01 Oct, 2008
Sorry but how it should submit if you don't have form.submit in your JS function ? does the code below work in HTML file without the form.submit line ?
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
GreyHead 01 Oct, 2008
Hi evenseabrook,

If you put this in the Form HTML
<input type="button" value="Submit" onClick="submitForm()">

and start the JavaScript like this:
function submitForm() {
var form = document.ChronoContact_Postal_Codes;
var total = form.txt1.value;
. . .

Then the code will run when you click the OnSubmit button - provided that you have a valid PostCode prefix in the input box.

But 'document.write' replaces the entire page so this part of the code still probably needs fixing.

Bob
evanseabrook 01 Oct, 2008
Ok, now we're cooking! Now it just shows an empty page after submitting. What i was going for was the write out all the results. If I turn debug on, all it shows is:
_POST: Array ( [select] => 1 [txt1] => S0E 1A0 )
Ideas?
GreyHead 01 Oct, 2008
Hi evanseabrook,

Very basic but try this in the OnSubmit before box:
<p>Postcode: {txt1}</p>


Bob
evanseabrook 01 Oct, 2008
You mean in the "On Submit code - before sending email:" box? That just seems to put the text Postcode: {txt1} after I submit. What are we trying to accomplish with this line? Just put the value of txt1 on the page for testing?
Max_admin 01 Oct, 2008
Hi evanseabrook,

I think there is some misunderstanding here, what you call "submit" is only a JS write for the current page, so the page is not submitted, instead you use JS to rewrite it!

I think you should replace all :
document.write("data");

with :
document.getElementById('ChronoContact_Postal_Codes').innerHTML += "data";

replace the word data with any text you add at any step, this will clear the form and add the output you need!

Cheers

Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
evanseabrook 01 Oct, 2008
Can you explain what:

document.getElementById('ChronoContact_Postal_Codes').innerHTML

...actually means?

FYI, I just did this and it is still NOT producing any output and the debugger shows "_POST: Array ( [select] => 1 [txt1] => S0E 1A0 ) "
Max_admin 01 Oct, 2008
I understand from you code that document.write only adding some text to the current page without submitting it so this piece :

document.getElementById('ChronoContact_Postal_Codes').innerHTML


adds the same text to the form area! you don't need to submit the form! your HTML code even doesn't have a submit button, only a normal button with JS function which does not submit so it submits ?
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
GreyHead 01 Oct, 2008
Hi both,

If the deBug output is showing then I think the form must be submitting. So I assumed that the document.write problem had been fixed.

Max's code will replace the whole form with the 'data' output.

Perhaps it would help if you tell us exactly what this form is supposed to do. At present you have a text box that looks up a post-code prefix in the currently selected list. But I don't see what the radio buttons do, it would be just as eay to look up the prefix from a single list with all of the postcodes in it.

Bob
evanseabrook 01 Oct, 2008
I'm glad you said that it'd be just as easy without the rb's. All this form does it allow someone to enter a postal code and then checks that value against a pre-existing list to see what rating calculation should be used (Metro 1, Metro 2, etc). It compares the first 3 characters entered to the first 3 characters in each array item. There are times where more than 1 item is returned (in the case of two postal codes starting with S7K). I was using the radio buttons to allow the user to select a province, then when submitted, only the array for that province would be searched (there are about 70 postal codes per array). If I don't use the radio buttons, I'll have 1 array with about 210 entries.

Here is the new HTML:

<html>
<body>
<b>Province:</b><br>
Postal Code: <input type="text" name="txt1"><br>
<input type="submit" value="Submit" onClick="submitForm()">
</body>
</html>

Here is the new JS (I've only added 10 entries to the array):

function submitForm() {
var form = document.ChronoContact_test;
var total = form.txt1.value;
var totalsub = total.substr(0,3);
var codesSk=new Array();
codesSk[1] = "S7H - Saskatoon - Metro 1";
codesSk[2] = "S7J - Saskatoon - Metro 1";
codesSk[3] = "S7K - Saskatoon - Metro 1";
codesSk[4] = "S7N - Saskatoon - Metro 1";
codesSk[5] = "S7P - Saskatoon - Metro 1";
codesSk[6] = "S7S - Saskatoon - Metro 1";
codesSk[7] = "S7T - Saskatoon - Metro 1";
codesSk[8] = "S7V - Saskatoon - Metro 1";
codesSk[9] = "S7W - Saskatoon - Metro 1";
codesSk[10] = "S7K - Regina - Metro 2";

for (var i = 1; i < codesSk.length; i++)
{
if (totalsub == codesSk[i].substr(0,3)){
document.getElementById('ChronoContact_test').innerHTML += codesSk[i];
document.getElementById('ChronoContact_test').innerHTML += <br />; }
else
{document.getElementById('ChronoContact_test').innerHTML += "Not found";}
}

The problem still remains where no output is created. I enter "S7K 2H8" in the text box, hit the submit button, the screen changes and shows a blank screen. With debug on, all it shows:
_POST: Array ( [txt1] => S7K 2H8 ) .

I think I'm missing a fundamental piece.
evanseabrook 01 Oct, 2008
I've been looking at this far too long....

..I didn't have a closing curly brace closing off the JS function. After putting it in, it outputted as expected! YAY....

Now, how do I clear the page of all the output. I'd like to clear it each time the button is clicked...
Max_admin 02 Oct, 2008
after the function submitform add this :

document.getElementById('ChronoContact_test').innerHTML = "";
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
evanseabrook 02 Oct, 2008
If I put it after the function starts (below function submitform()) it clears the whole page. I need it to just clear the stuff displayed with:
document.getElementById('ChronoContact_test').innerHTML += codes[i];
document.getElementById('ChronoContact_test').innerHTML += "<br />";

I'm assuming document.getElementById('ChronoContact_test').innerHTML = ""; clears the whole page? Basically, refresh the search.
GreyHead 02 Oct, 2008
Hi evanseabrook,

The JavaScript:

document.getElementById('some_id').innerHTML = "some html";

will replace the contents of the element with id='someid' with whatever is in "some_html"

So I suggest that you add a
<div id="results"></div>
to your page and write the out put to this.

Bob
evanseabrook 02 Oct, 2008
That's a great idea! :mrgreen: Curiously though, now after clicking the "submit" button, the new DIV is populated with the results but then the page seems to refresh and the screen blanks out (the labes, text box, results and Submit button all are cleared out).

for (var i = 1; i < codes.length; i++)
{
if (totalsub == codes[i].substr(0,3)){
document.getElementById('results').innerHTML += codes[i];
document.getElementById('results').innerHTML += "<br />";}
}


UPDATE.....Because the button in HTML was a type=submit. I changed it to type=button and now it doesn't unexpectedly refresh the screen! Also, now the document.getElementById('results').innerHTML += ""; line works! Excellent! Thanks for all your help!....
Max_admin 02 Oct, 2008
Sure, we are working on this based on your HTML code at the first post which has the button of type button and not submit!🙂 anyway glad it works now!

Cheers

Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
GreyHead 02 Oct, 2008
Hi evanseabrook,

Here's a version that works OK.
[attachment=0]02-10-2008 19-09-40.png[/attachment]
Form HTML:
<b>Province:</b><br>
<input type="radio" name="select" id="radio1" value="1" /> Saskatchewan<br />
<input type="radio" name="select" id="radio2" value="2" /> Alberta<br />
<input type="radio" name="select" id="radio3" value="3" /> Manitoba<br />
Postal Code: <input type="text" name="txt1"><br>
<input type="button" value="Search" onClick="submitForm()">
<div id="results" style='font-weight:bold; color:blue;' >Your result here</div>

and JavaScript
function submitForm() {
    var form = document.ChronoContact_Postal_Codes;
    var new_text = "Sorry, we didn't find that code.";
    var total = form.txt1.value;
    var totalsub = total.substr(0,3);
    var codesSk = new Array();
    var codesMB = new Array();
    var codesAB = new Array();
    codesSk[1] = "S7H - Saskatoon - Metro 1";
        codesSk[2]  = "S7J - Saskatoon - Metro 1";
        codesSk[3]  = "S7K - Saskatoon - Metro 1";
        codesSk[4]  = "S7N - Saskatoon - Metro 1";
        codesSk[5]  = "S7P - Saskatoon - Metro 1";
        codesSk[6]  = "S7S - Saskatoon - Metro 1";
        codesSk[7]  = "S7T - Saskatoon - Metro 1";
        codesSk[8]  = "S7V - Saskatoon - Metro 1";
        codesSk[9]  = "S7W - Saskatoon - Metro 1";
        codesSk[10] = "S4L - Regina - Metro 2";

        codesMB[1]  = "R2E - Winnipeg - Metro 1";
        codesMB[2]  = "R2J - Winnipeg - Metro 1";
        codesMB[3]  = "R2M - Winnipeg - Metro 1";
        codesMB[4]  = "R2P - Winnipeg - Metro 1";
        codesMB[5]  = "R3J - Winnipeg - Metro 1";
        codesMB[6]  = "R3K - Winnipeg - Metro 1";
        codesMB[7]  = "R3P - Winnipeg - Metro 1";
        codesMB[8]  = "R3R - Winnipeg - Metro 1";
        codesMB[9]  = "R3S - Winnipeg - Metro 1";
        codesMB[10] = "R3T - Winnipeg - Metro 1";

        codesAB[1]  = "T5A - Edmonton - Metro 1";
        codesAB[2]  = "T5C - Edmonton - Metro 1";
        codesAB[3]  = "T5K - Edmonton - Metro 1";
        codesAB[4]  = "T5N - Edmonton - Metro 1";
        codesAB[5]  = "T5R - Edmonton - Metro 1";
        codesAB[6]  = "T5S - Edmonton - Metro 1";
        codesAB[7]  = "T5T - Edmonton - Metro 1";
        codesAB[8]  = "T5X - Edmonton - Metro 1";
        codesAB[9]  = "T5Z - Edmonton - Metro 1";
        codesAB[10] = "T6A - Edmonton - Metro 1";

    if (document.getElementById('radio1').checked) {
        for ( var i = 1; i < codesSk.length; i++ ) {
            if ( totalsub == codesSk[i].substr(0,3) ) {
                new_text = codesSk[i]+"<br />";
            }
        }
    } else if (document.getElementById('radio2').checked) {
        for (var i = 1; i < codesAB.length; i++) {
            if ( totalsub == codesAB[i].substr(0,3) ) {
                new_text = codesAB[i]+"<br />";
            }
        }
    } else if (document.getElementById('radio3').checked) {
        for (var i = 1; i < codesMB.length; i++) {
            if ( totalsub == codesMB[i].substr(0,3) ) {
                new_text = codesMB[i]+"<br />";
            }
        }
    }
    document.getElementById('results').innerHTML = new_text;
}


Bob

PS This isn't necessarily the best way of doing it but this is a working example for you to build on.
PPS If you hit enter, instead of clicking the Search button the form will submit and you get a small mess!
evanseabrook 02 Oct, 2008
Bob, I did notice that (with regards to the Enter button)....I'll have to look into my options...
I retract my previous post...I found the 153 limitation...my programming skills (or lack there of!!) I had two array items with the same index.
Max_admin 02 Oct, 2008
Sure an issue with the JS or your code, I did take a quick look and can't see anything wrong with your code and I never passed by this issue in JS, So I wish you will find a fix!🙂

Cheers

Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
GreyHead 02 Oct, 2008
Hi evanseabrook,

Ah, glad you found the error, the theortical limit to a JavaScript array is 4,294,967,295 so I thought it must be a typo somewhere.

Bob
evanseabrook 02 Oct, 2008
Last post, promise:

Here is the working code (to cope with hitting enter, I put a custom message in saying go back and hit the Search button). I also put in a flag so if the search results in nothing a message is produced. Thanks Bob and Max for all your help...after doing this form, I just might try another!

HTML:
<html>
<body>
<b><p align=center><font color=blue size=5>Classification Lookup By Postal Code</font><b>
<br>
<br>
<p align=center>Postal Code: <input type="text" name="txt1"><br>
<p align=center><input type="button" value="Search" onClick="submitForm()"></p>
Results:
<div id="results"></div><br>
</body>
<p align=center><a href=http://pagesperso-orange.fr/universimmedia/geo/loc.htm target="_blank">Click Here to search for locations above the 55th parallel.
<br>
<br>
<br>
<br>
</html>


JavaScript:
function submitForm(){
document.getElementById('results').innerHTML = "";
var j = 0;
var form = document.ChronoContact_PostalCodeSearch;
var total = form.txt1.value.toUpperCase();
var totalsub = total.substr(0,3);
var codes=new Array();
codes[1] = "S7H - Saskatoon - Metro 1";
codes[2] = "S7J - Saskatoon - Metro 1";
codes[3] = "S7K - Saskatoon - Metro 1";
codes[4] = "S7N - Saskatoon - Metro 1";
codes[5] = "S7P - Saskatoon - Metro 1";
codes[6] = "S7S - Saskatoon - Metro 1";
codes[7] = "S7T - Saskatoon - Metro 1";
codes[8] = "S7V - Saskatoon - Metro 1";
codes[9] = "S7W - Saskatoon - Metro 1";
codes[10] = "S4L - Regina - Metro 2";
codes[11] = "S4R - On McCarthy Blvd - Metro 2";
codes[12] = "S4S - Regina - Metro 2";
codes[13] = "S4V - Regina - Metro 2";
codes[14] = "S4W - Regina - Metro 2";
codes[15] = "S4X - Regina - Metro 2";
codes[16] = "S4Y - Regina - Metro 2";
codes[17] = "S4Z - Regina - Metro 2";
codes[18] = "S0P 0A0 - Creighton - Metro 3";
codes[19] = "S0P 0B0 - Denare Beach - Metro 3";
codes[20] = "S0M 0E0 - Battleford - Metro 3";
codes[21] = "S6V - Prince Albert - Metro 3";
codes[22] = "S6W - Prince Albert - Metro 3";
codes[23] = "S6X - Prince Albert - Metro 3";
codes[24] = "S9A - North Battleford - Metro 3";
codes[25] = "S4A - Estevan - Metro 4";
codes[26] = "S0E 1A0 - Melfort - Metro 4";
codes[27] = "S0E 1E0 - Nipawin - Metro 4";
codes[28] = "S0E 1T0 - Tisdale - Metro 4";
codes[29] = "S0K 2A0 - Humboldt - Metro 4";
codes[30] = "S9V - Lloydminster, SK - Metro 4";
codes[31] = "T9V - Lloydminster, AB - Metro 4";
codes[32] = "S0A 2P0 - Melville - Metro 4";
codes[33] = "S9H - Swift Current - Metro 4";
codes[34] = "S0L - Kindersley - Metro 4";
codes[35] = "S7L - Saskatoon - Metro 5";
codes[36] = "S7M - Saskatoon - Metro 5";
codes[37] = "S7R - Saskatoon - Metro 5";
codes[38] = "S4N - Regina: West of Ring Road - Metro 5";
codes[39] = "S4P - Regina - Metro 5";
codes[40] = "S4T - Regina: West of McCarthy Blvd - Metro 2";
codes[41] = "S4T - Regina: East of McCarthy Blvd - Metro 5";
codes[42] = "S4N - Regina: East of Ring Road - Metro 2";
codes[43] = "S4R - Regina: West of Ring Road - Metro 5";
codes[44] = "S4R - Regina: South of Ring Road and 9th Ave N - Metro 5";
codes[45] = "S4R - Regina: North of Ring Road and 9th Ave N - Metro 2";
codes[46] = "S4H - Weyburn - Metro 4";
codes[47] = "R2E - Winnipeg - Metro 1";
codes[48] = "R2J - Winnipeg - Metro 1";
codes[49] = "R2M - Winnipeg - Metro 1";
codes[50] = "R2P - Winnipeg - Metro 1";
codes[51] = "R3J - Winnipeg - Metro 1";
codes[52] = "R3K - Winnipeg - Metro 1";
codes[53] = "R3P - Winnipeg - Metro 1";
codes[54] = "R3R - Winnipeg - Metro 1";
codes[55] = "R3S - Winnipeg - Metro 1";
codes[56] = "R3T - Winnipeg - Metro 1";
codes[57] = "R3V - Winnipeg - Metro 1";
codes[58] = "R3X - Winnipeg - Metro 1";
codes[59] = "R3Y - Winnipeg - Metro 1";
codes[60] = "R4A - Winnipeg - Metro 1";
codes[61] = "R0G 0B0 - Altona - Metro 2";
codes[62] = "R0C 0A0 - Arborg - Metro 2";
codes[63] = "R0E 0C0 - Beausejour - Metro 2";
codes[64] = "R0K 0E0 - Bouissevain - Metro 2";
codes[65] = "R0J 1E0 - Minnedosa - Metro 2";
codes[66] = "R0J 1H0 - Neepawa - Metro 2";
codes[67] = "R6M - Morden - Metro 2";
codes[68] = "R1N - - Portage La Prairie - Metro 2";
codes[69] = "R0M - Virden - Metro 2";
codes[70] = "R7N - Dauphin - Metro 2";
codes[71] = "R0K 1G0 - Killarney - Metro 2";
codes[72] = "R0J 1W0 - Russell - Metro 2";
codes[73] = "R0C 1B0 - Gimli - Metro 2";
codes[74] = "R0C 1B1 - Gimli - Metro 2";
codes[75] = "R6W - Winkler - Metro 2";
codes[76] = "R0G - Carman - Metro 2";
codes[77] = "R0L 1P0 - Roblin - Metro 2";
codes[78] = "R0E 1L0 - Pinawa - Metro 2";
codes[79] = "R0L 1Z0 - Swan River - Metro 2";
codes[80] = "R0K 2C0 - Souris - Metro 2";
codes[81] = "R2G - Winnipeg - Metro 3";
codes[82] = "R2H - Winnipeg - Metro 3";
codes[83] = "R2K - Winnipeg - Metro 3";
codes[84] = "R2V - Winnipeg - Metro 3";
codes[85] = "R2Y - Winnipeg - Metro 3";
codes[86] = "R3L - Winnipeg - Metro 3";
codes[87] = "R3M - Winnipeg - Metro 3";
codes[88] = "R3N - Winnipeg - Metro 3";
codes[89] = "R3W - Winnipeg - Metro 3";
codes[90] = "R2C - Winnipeg - Metro 5";
codes[91] = "R2L - Winnipeg - Metro 5";
codes[92] = "R2R - Winnipeg - Metro 5";
codes[93] = "R2W - Winnipeg - Metro 5";
codes[94] = "R2X - Winnipeg - Metro 5";
codes[95] = "R3A - Winnipeg - Metro 5";
codes[96] = "R3B - Winnipeg - Metro 5";
codes[97] = "R3C - Winnipeg - Metro 5";
codes[98] = "R3E - Winnipeg - Metro 5";
codes[99] = "R3G - Winnipeg - Metro 5";
codes[100] = "R3H - Winnipeg - Metro 5";
codes[101] = "R7A - Brandon - Metro 6";
codes[102] = "R7B - Brandon - Metro 6";
codes[103] = "R7C - Brandon - Metro 6";
codes[104] = "R0C 2Z0 - Stonewall - Metro 6";
codes[105] = "R5G - Steinbach - Metro 6";
codes[106] = "T5A - Edmonton - Metro 1";
codes[107] = "T5C - Edmonton - Metro 1";
codes[108] = "T5K - Edmonton - Metro 1";
codes[109] = "T5N - Edmonton - Metro 1";
codes[110] = "T5R - Edmonton - Metro 1";
codes[111] = "T5S - Edmonton - Metro 1";
codes[112] = "T5T - Edmonton - Metro 1";
codes[113] = "T5X - Edmonton - Metro 1";
codes[114] = "T5Z - Edmonton - Metro 1";
codes[115] = "T6A - Edmonton - Metro 1";
codes[116] = "T6E - Edmonton - Metro 1";
codes[117] = "T6G - Edmonton - Metro 1";
codes[118] = "T6H - Edmonton - Metro 1";
codes[119] = "T6J - Edmonton - Metro 1";
codes[120] = "T6K - Edmonton - Metro 1";
codes[121] = "T6L - Edmonton - Metro 1";
codes[122] = "T6M - Edmonton - Metro 1";
codes[123] = "T6N - Edmonton - Metro 1";
codes[124] = "T6R - Edmonton - Metro 1";
codes[125] = "T6S - Edmonton - Metro 1";
codes[126] = "T6T - Edmonton - Metro 1";
codes[127] = "T6V - Edmonton - Metro 1";
codes[128] = "T6W - Edmonton - Metro 1";
codes[129] = "T6X - Edmonton - Metro 1";
codes[130] = "T6Z - Edmonton - Metro 1";
codes[131] = "T8A - Sherwood Park - Metro 1";
codes[132] = "T8B - Sherwood Park - Metro 1";
codes[133] = "T8C - Sherwood Park - Metro 1";
codes[134] = "T8E - Sherwood Park - Metro 1";
codes[135] = "T8G - Sherwood Park - Metro 1";
codes[136] = "T8H - Sherwood Park - Metro 1";
codes[137] = "T8N - St. Albert - Metro 1";
codes[138] = "T0K 0G0 - Bow Island - Metro 2";
codes[139] = "T0J 1A0 - Dunmore - Metro 2";
codes[140] = "T0J 1A1 - Dunmore - Metro 2";
codes[141] = "T0J 1V0 - Irvine - Metro 2";
codes[142] = "T1A - Medicine Hat - Metro 2";
codes[143] = "T1B - Medicine Hat - Metro 2";
codes[144] = "T1C - Medicine Hat - Metro 2";
codes[145] = "T0J 2N0 - Ralston - Metro 2";
codes[146] = "T0J 2P0 - Redcliff - Metro 2";
codes[147] = "T0J 2P2 - Redcliff - Metro 2";
codes[148] = "T0K 1Z0 - Seven Persons - Metro 2";
codes[149] = "T0J 3L0 - Walsh - Metro 2";
codes[150] = "T1Y - Calgary - Metro 3";
codes[151] = "T2A - Calgary - Metro 3";
codes[152] = "T2B - Calgary - Metro 3";
codes[153] = "T2E - Calgary - Metro 3";
codes[154] = "T2G - Calgary - Metro 3";
codes[155] = "T3J - Calgary - Metro 3";
codes[156] = "T5B - Edmonton - Metro 3";
codes[157] = "T5E - Edmonton - Metro 3";
codes[158] = "T5G - Edmonton - Metro 3";
codes[159] = "T5H - Edmonton - Metro 3";
codes[160] = "T5J - Edmonton - Metro 3";
codes[161] = "T5L - Edmonton - Metro 3";
codes[162] = "T5M - Edmonton - Metro 3";
codes[163] = "T5P - Edmonton - Metro 3";
codes[164] = "T5V - Edmonton - Metro 3";
codes[165] = "T5W - Edmonton - Metro 3";
codes[166] = "T6B - Edmonton - Metro 3";
codes[167] = "T6C - Edmonton - Metro 3";
codes[168] = "T6P - Edmonton - Metro 3";
codes[169] = "T2C - Calgary - Metro 4";
codes[170] = "T2H - Calgary - Metro 4";
codes[171] = "T2J - Calgary - Metro 4";
codes[172] = "T2K - Calgary - Metro 4";
codes[173] = "T2L - Calgary - Metro 4";
codes[174] = "T2M - Calgary - Metro 4";
codes[175] = "T2N - Calgary - Metro 4";
codes[176] = "T2P - Calgary - Metro 4";
codes[177] = "T2R - Calgary - Metro 4";
codes[178] = "T2S - Calgary - Metro 4";
codes[179] = "T2T - Calgary - Metro 4";
codes[180] = "T2V - Calgary - Metro 4";
codes[181] = "T2W - Calgary - Metro 4";
codes[182] = "T2X - Calgary - Metro 4";
codes[183] = "T2Y - Calgary - Metro 4";
codes[184] = "T2Z - Calgary - Metro 4";
codes[185] = "T3A - Calgary - Metro 4";
codes[186] = "T3B - Calgary - Metro 4";
codes[187] = "T3C - Calgary - Metro 4";
codes[188] = "T3E - Calgary - Metro 4";
codes[189] = "T3G - Calgary - Metro 4";
codes[190] = "T3H - Calgary - Metro 4";
codes[191] = "T3K - Calgary - Metro 4";
codes[192] = "T3L - Calgary - Metro 4";
codes[193] = "T3M - Calgary - Metro 4";
codes[194] = "T3N - Calgary - Metro 4";
codes[195] = "T3P - Calgary - Metro 4";
codes[196] = "T3R - Calgary - Metro 4";

	for (var i = 1; i < codes.length; i++)
	{
		if (totalsub == codes[i].substr(0,3))
		{
			j++;
			document.getElementById('results').innerHTML += codes[i];
			document.getElementById('results').innerHTML += "<br />";
		}
	}
	if (j == 0 )
	{
		document.getElementById('results').innerHTML += "Please check that the Postal Code is valid.  If it is, please refer to rules for Classification Table 1, Table 2 or Table 3.";
	}
}
This topic is locked and no more replies can be posted.