I have been developing a small application for a client which combines two arrays together and then creates a URL and then loads the images on the same page from the given URL.
I'd like you to look at my code and give feedback on how to make it more maintainable and robust.
function displayContent() {
document.getElementById("findCar").onsubmit = function () {
var registration = document.getElementById("regPlate").value,
reference = document.getElementById("stockRef").value;
var regArray = registration.split(''),
refArray = reference.split(''),
referenceNinth = refArray[10];
reverseReg = regArray.reverse();
var obfuscated = new Array();
var obf_index = 0;
for (i = 0; i <= 6; i++) {
obfuscated[obf_index] = refArray[i];
obf_index++;
obfuscated[obf_index] = reverseReg[i];
obf_index++;
}
obfuscated.push(referenceNinth);
obfuscatedString = obfuscated.join("");
var camera = new Array();
var cameraSize = "350";
var cam_index = 0;
for (i = 0; i <= 1; i++) {
if (i > 0) cameraSize = "800";
camera[cam_index++] = cameraSize + "/f";
camera[cam_index++] = cameraSize + "/i";
camera[cam_index++] = cameraSize + "/6";
camera[cam_index++] = cameraSize + "/5";
camera[cam_index++] = cameraSize + "/4";
camera[cam_index++] = cameraSize + "/r";
}
for (i = 0; i <= 11; i++) {
var img = new Image();
img.src = 'http://imagecache.arnoldclark.com/imageserver/" + obfuscatedString + "/" + camera[i] + "'
document.body.appendChild(img);
}
return false;
};
}