Skip to main content
Participant
April 26, 2019
Question

If a field already has a value, how can I tell the next value to go to another field?

  • April 26, 2019
  • 1 reply
  • 680 views

I have two forms:

The first shows a list of 100 products, each with a check box.  If a product is used that day, I check the box-- typically between 3 to 10 products used per day.  For instance, today I used Q,R,V, X, and Z, and so I check the corresponding boxes.

On the second there are 20 rows for inputting the keycode and quantity used for each product that was checked off on page 1.  For instance, when I checked off the box for product Q on the first page, on this page I specify that the keycode for Q is 1032, and I used 7 of them.  The next line says that R's keycode is 4402 and I used 2 of them, V is 5001 and I used 1 of them, etc.

I've got a simple script for autopopulating the corresponding keycode on page 2 when the checkbox on page 1 is checked.  HOWEVER, that only works for row 1.  So when I check the box for using product Q on page 1, on the first row of page 2 it automatically writes "1032" into the keycode column.  But when I say I also used product V, it just writes "5001" over product Q's keycode.

You can see my problem.  I need a way to tell the second (then third, then fourth...)  box I check that if there is already a keycode entered on row 1, it should enter the keycode onto row 2, and if that's also been filled, go to row 3, then row 4, etc., all the way to row 20.

It might not be elegant, but it would save an incredible amount of time.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
April 26, 2019

It's certainly possible. Could you post your existing code? It's just a question of adjusting it to do it.

Also, we would need to know the names of the fields involved.

Participant
April 26, 2019

When the checkbox for Digital Camera (keycode is "0483"), this script runs.

//checkbox1 code

var v = event.target.value;

var f3 = this.getField("kc1");

if (v != "Off") {

    f3.value = "0483";

    f3.readonly = true;

}

else {

    f3.value = "";

    f3.readonly = false;

}

Each box of the keycode column is numbered, so here "kc1" is the keycode for the first row.  So right now I'm only able to assign checkboxes to keycodes on a specific cell.   I need a way to assign the checkboxes to fill in the keycodes from top down in the column.

try67
Community Expert
Community Expert
April 26, 2019

So are the other fields named "kc2", "kc3", etc.? How many such fields are there?