안녕하세요, 저는 반쪽으로 작동하는 응용 프로그램이 있습니다. 각 개체의 속성이 이미 설정된 배열이 있으며이 개체를 myarray[i].property
과 같이 호출 할 수 있습니다. 루프 내에서 배열을 검색하는 if 문을 가지고 있으며 어디에서든지 코드를 추출합니다. myarray[i].property == my var
.어떻게하면 자바 스크립트 루프를 사용하여 객체의 배열을 만들 수 있습니까
내가 겪고있는 문제는 첫 번째 배열을 검색하는 if statment/loop 콤보에 의해 작성된 새로운 배열에 이러한 결과를 넣고 싶습니다. 작동하지 못하는 것입니다.
이것은 내가 시도했지만 실패한 것입니까?
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;}
은 또한 코드에서 내가 줄을 내가 잘못 가고
document.getElementById('servoDisplay').innerHTML = "search result " + matches[c].modelno; //display servos model numbers stored within the matches array
이 왜 난 항상받을 수 있나요 '.modelno null 또는 정의되지 않은'내가 경기를 호출 할 때마다 오류 [C]. 모델 번호?
'mew'는 실제로'new'라고 가정합니까? –
예전에 오타가 오타되었으므로 코드를 복사하여 붙여 넣지 않았습니다.이 PC와는 다른 PC에 있습니다. –
C 값을 다시 설정합니까? ...? – geekchic