In the second function , the array is coming up as undefined. Any Ideas ?
Code:
<script type="text/javascript">
var year = ["1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014","2014"];
var plateYear = ["97", "98", "99", "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "131", "132", "141", "142" ];
var counties = ["Cork", "Clare", "Cavan", "Carlow", "Dublin", "Donegal", "Galway", "Kildare", "Kilkenny", "Kerry", "Limerick", "Longford", "Louth", "Leitrim", "Laois", "Meath", "Monaghan", "Mayo", "Offaly", "Roscommon", "Sligo", "North Tipperary", "South Tipperary", "Waterford", "Westmeath", "Wexford", "Wicklow" ];
var plates = ["C", "CE", "CN", "CW", "D", "DL", "G", "KE", "KK", "KY", "L", "LD", "LH", "LM", "LS", "MH", "MN", "MO", "OY", "RN", "SO", "TN", "TS", "W", "WH", "WX", "WW" ];
function formGet (form)
{
event.preventDefault();
console.log(form);
var carYear = form.reg1.value;
console.log("reg1" + carYear);
var b = carYear.toString();
var a = plateYear.indexOf(b);
console.log("a" + a);
var newYear = year [a];
alert("Year Car was made : " + newYear);
event.preventDefault();
console.log(form);
var carCounties = form.reg2.value;
console.log("reg2" + plates);
var b = counties.toString();
var a = plates.indexOf(b);
console.log("a" + a);
var newCounty = carCounties [a];
alert ("County where car was registered : " + newCounty);
}
Comment