Really, it's a JavaScript question.
You neglect to actually mention *what* doesn't work, just saying "it doesn't work" is not helpful:
TellTheDetails.
That said, if you're trying to change 10 text fields, it'd make sense to have the JavaScript change 10 text fields--yours changes only a single text field, which is around 9 short. Perhaps a loop, or in any reasonable JavaScript library, a selector with a function.