I want to dynamically change a part (number) in the object name in the code.
I am a complete beginner.
This is a very rudimentary question.
I am creating a slightly spreadsheet-like form.
Objectize each field as follows.
Intuitively, A, B and C are vertical columns.
Think of 12345 as a row.
var A1 = this.getField("A_1");
var A2 = this.getField("A_2");
var A3 = this.getField("A_3");
var A4 = this.getField("A_4");
var A5 = this.getField("A_5");
var B1 = this.getField("B_1");
var B2 = this.getField("B_2");
var B3 = this.getField("B_3");
var B4 = this.getField("B_4");
var B5 = this.getField("B_5");
var C1 = this.getField("C_1");
var C2 = this.getField("C_2");
var C3 = this.getField("C_3");
var C4 = this.getField("C_4");
var C5 = this.getField("C_5");
I am trying to copy the value entered in the specified C field to B based on the value entered in A.
Each row has a button, and the following JavaScript is embedded in the button.
Very simple code.
if(A1.value == 3000){B1.value = C1.value;}
if(A1.value == 6000){B1.value = C2.value;}
if(A1.value == 12000){B1.value = C3.value;}
if(A1.value == 24000){B1.value = C4.value;}
if(A1.value == 36000){B1.value = C5.value;};
The problem is that I have to place this code on a button on every line.
The second line looks like this.
if(A2.value == 3000){B2.value = C1.value;}
if(A2.value == 6000){B2.value = C2.value;}
if(A2.value == 12000){B2.value = C3.value;}
if(A2.value == 24000){B2.value = C4.value;}
if(A2.value == 36000){B2.value = C5.value;};
The third line looks like this.
if(A3.value == 3000){B3.value = C1.value;}
if(A3.value == 6000){B3.value = C2.value;}
if(A3.value == 12000){B3.value = C3.value;}
if(A3.value == 24000){B3.value = C4.value;}
if(A3.value == 36000){B3.value = C5.value;};
This is very time consuming when writing code...
I want to make about 300 buttons like this.
In the above example, the numbers must be rewritten 10 times per line.
I want to do this with one rewrite.
Isn't it possible to assign the number of the object name indicating the line in any way?
I tried various things, but none worked well.
Thanks for your guidance.
