jquery - JavaScript array search to return index position for 2 element search -


i need search json set 2 elements of array. if match found these 2 elements, need index of position. , once have index, can use access different property in same array position.

below sample of have. if @ line 22, hard-coding array position 1. value dynamically need depending on pass getmodelid() function.

http://codepen.io/bdang/pen/pjvmox/?editors=101

function getmodelid(extclr, intclr) {      var colorlockdatesar = lockdates.models[0].colors,         colorlockdatescount = colorlockdatesar.length;      for(var = 0; < colorlockdatescount; i++) {                if(colorlockdatesar[i].extcolorcd == extclr && colorlockdatesar[i].intcolorcd == intclr) {                        $('#modelid').html(colorlockdatesar[1].modelid);          }        }    }  getmodelid('bk', 'bk'); // should return model 1 getmodelid('bk', 'wh'); // should return model 2 getmodelid('wh', 'bk'); // should return model 3 

i have looked through various forums , many issues i've found related issues none specific need. appreciated.

just pass i

$('#modelid').html(colorlockdatesar[i].modelid); 

http://codepen.io/moogs/pen/xgbnvg


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -