Reputation: 383
I want to access values of below elments
opener.document.EditView.flight_no1_c.value
opener.document.EditView.flight_no2_c.value
opener.document.EditView.flight_no3_c.value
opener.document.EditView.flight_no4_c.value
Here only numbers are changing ranging from 1 to 4. How can I make this into loop.
Upvotes: 0
Views: 68
Reputation: 12043
what about
for(var key in opener.document.EditView){
if(key.match(/^flight_no\d+_c/)){
console.log(key.value);
}
}
Upvotes: 0
Reputation: 12127
You can use for
loop and call properly using []
insteand on .
, see below code
for(var i = 1; i <= 4; i++ ){
opener.document.EditView["flight_no"+i+"_c"].value
}
Upvotes: 2