Hi,
I have been working on a function that is giving me a hard time. I have posted several times to this forum and I am not receiving the help I need. Since the previous posts, I have made some changes and improvements to the function.
The getModelsByMake(mType) function should loop through the myAutos array objects and retrieve the models that are a specific type based on the (mType). It's 1/2 way working now and you can see the results for the "Ford" selection at the following URL: http://7079.net/cars_objects_ara.html
It should only output "Crown Victoria|Crown Victoria, Taurus|Taurus", but it also is outputting everything else in the array object. If someone chooses "Nissan" as the parameter to pass to the function, they will receive the vehicles that are Nissan only.
I have output the 3 results for the 3 makes that I currently have in the array. If anyone can help me please, I would appreciate it so much. No one has been responding to my requests and this function is becomming frustrating without expert help.
BTW, someone mentioned in a previous post of mine that the HTML is not to code etc.... The class that I am doing this for is a JS class and HTML is not being graded. I understand the importance of proper HTML, but for this, it is the function that is important.
Here is the function:
[code]
var models3 = new Array(); //to be global scope
function getModelsByMake(mType){
this.mType = mType;
var md = myAutos[0].model + "|" + myAutos[0].model;
models3[0] = md;
mdIndex = 0;
for(var i = 0;i<myAutos.length;i++){
if((myAutos[i].model + "|" + myAutos[i].model) === md && myAutos[i].make === mType){
continue;
}
else{
md = myAutos[i].model + "|" + myAutos[i].model;
models3[++mdIndex] = md;
}
}
}
[code]
Thanks,
7079



Reply With Quote

Bookmarks