Writing /volume1/Web/Public/dokuwiki/data/log/deprecated/2024-11-14.log failed
Writing /volume1/Web/Public/dokuwiki/data/log/deprecated/2024-11-14.log failed

Initialize an Array

1) Initialize the array when the load event is fired.

var initArray = [];
function init() {
  var fE = document.forms['testForm'].elements;
 
  for(var i = 0; i < 4; i++) {
    initArray[i] = fE['field' + (i + 1)];
  }
}//

2) Store the field names and look them up in your functions

var initArray = ['field1', 'field2', 'field3', 'field4'];
 
function getValuesA() {
  var v = ['One', 'Two', 'Three', 'Four'],
  fE = document.forms['testForm'].elements;
 
  for(var i = 0; i < 4; i++) {
   fE[initArray[i]].value = v[i];
  }
}

コメント

コメントを入力. Wiki文法が有効です:
O Y H N H
 

QR Code
QR Code study:javascript:array (generated for current page)