S
S
sskalmykov2011-09-19 11:50:03
JavaScript
sskalmykov, 2011-09-19 11:50:03

Bulk change input values ​​by classname

Hello js gurus. Tell me how to change the values ​​​​at once of a large number (more than 50) of the input fields to the given one.
Those. I want the values ​​of these fields to become equal to the given number when the button is clicked.
Prototype is used (I don't know how useful this information is).

This document.getElementsByClassName('counts')[0].value='99'" does not help. More precisely, only the value of the first element changes.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
@
@antoo, 2011-09-19
@sskalmykov

var elems = document.getElementsByClassName('counts');
for(i=0; i<elems.length; i++) {
  elems[i].value = '99';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question