Hi I have an application that I have got half working. I have an array of objects, each with their properties already set and can call them like this myarray[i].property
. I have an if statment that searchs through the array, within a loop, and pulls out any where myarray[i].property == my var
.
The issue I'm having is that I want to put these results into a new array, built by the if statment/loop combo that searchs the first array, and I can't make it work.
This is what I have tried, but failed with?
var c = 0;
var matches = new Array('application', 'sclass', 'type', 'motor', 'bearings', 'gears', 'modelno', 'name', 'speed', 'v3_3', 'v4_8', 'v6_0', 'v7_2', 'weight', 'diensions', 'opvoltage', 'image', 'description');
//loop through servos array and pull any servo that has a matching application value to that selected by the search filter
for(var i=0; i < servos.length; i++){
if servos[i].application == document.searchFilters.applicationMenu.value) {
//populate the new 'matches' array with the details from the servos pulled from the inital arary
matches[c] = new servo(servos[i].application, servos[i].sclass, servos[i].type, servos[i].motor, servos[i].bearings, servos[i].gears, servos[i].modelno, servos[i].name, servos[i].speed, servos[i].v3_3, servos[i].v4_8, servos[i].v6_0, servos[i].v7_2, servos[i].weight, servos[i].dimensions, servos[i].opvoltage, servos[i].image, servos[i].description);
c++;
} else if (document.searchFilters.applicationMenu.value == 0){
//sets the value of servoDtore locally
var servoStore = 0;}
Further in the code I have the line document.getElementById('servoDisplay').innerHTML = "search result " + matches[c].modelno; //display servos model numbers stored within the matches array
Where am I going wrong, why do I always get '.modelno is null or undefined' errors whenever I try to call matches[c].modelno?
mew
is actuallynew
? – Felix Kling Oct 10 '11 at 8:44