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

New Here ,
Apr 26, 2019

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript

Views

60

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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

New Here ,
Apr 26, 2019

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript

Views

61

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 26, 2019 0
Most Valuable Participant ,
Apr 26, 2019

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
New Here ,
Apr 26, 2019

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
Most Valuable Participant ,
Apr 26, 2019

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
New Here ,
Apr 26, 2019

Copy link to clipboard

Copied

Yes, the names follow that convention.  There are 20 total rows.  The issue is that there's any possible combination of the 100 products that would go to that column, though typically no more than 10 are used at a time.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
Most Valuable Participant ,
Apr 26, 2019

Copy link to clipboard

Copied

I think the approach to this should be different. I would do it using a calculation script of a (hidden) text field that checks all of the check-boxes and collects the data from the ticked ones into an array, and then copies the data from that array into the text fields.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
New Here ,
Apr 26, 2019

Copy link to clipboard

Copied

Oh boy, I think you lost me on that one.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0
try67 LATEST
Most Valuable Participant ,
Apr 26, 2019

Copy link to clipboard

Copied

Yes, this will require a more complex script, in a way, but it's a much better approach than doing it through the Mouse Up event of each of the check-boxes and will be easier to maintain in the long run.

If you're interested I could develop this code for you, for a small fee. You can contact me privately (try6767 at gmail.com) to discuss it further.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2019 0