Expand my Community achievements bar.

SOLVED

Need dropdown choice from one table to be added to a new table with a click of a button

Avatar

Level 6

Good day,  I have a table which have dropdown lists within it. The table also have several buttons.  One of them is a button which adds a new blank table so that the user can choose whatever they like from the dropdown lists.  There are incidents where a choice from one of the drop down lists will be the same for multiple tables.  I do not want the user to have to choose the same choice every time they create a new table.  I would like the user to click another button which would add the additional table, and also keep certain choices selected in the previous table so that they don't have to choose it every time they create a new table.  Is this possible?  Just to elaborate more:  Example:  The table lists automobiles.  Within the table the user will need to enter 30 automobiles made by "Ford" but the automobiles have different models.  When the user chooses "Ford" from the drop down menu of the first table and enter all pertinent information, I want  "Ford" to be automatically entered into the next table when the button to create a similar table is chosen.

1 Accepted Solution

Avatar

Correct answer by
Employee

Please check this form in which I have copied the value from the dropdown in one table to the other table, on the click of a button - "Copy".

 

Mayank_Tiwari_0-1640784871037.png

 

 

 

View solution in original post

14 Replies

Avatar

Correct answer by
Employee

Please check this form in which I have copied the value from the dropdown in one table to the other table, on the click of a button - "Copy".

 

Mayank_Tiwari_0-1640784871037.png

 

 

 

Avatar

Level 6

Good day,

I'm not sure if this will work.  Your reply is listing "Table2".  Will another table "Table 3" appear listing the same value in it when they click the button again? I will need the form to work like this even if they click it 30 times.  Right now, I have another button on the form which adds a whole blank Table.  In the click event of that button, I have

"if (xfa.host.version<8) {

    xfa.form.recalculate(1);

}

I would like the other button to also add a whole new Table but keep whatever was chosen in the previous Table.

Avatar

Level 6

Good day,

I'm still in need of assistance on this....Please see my questions below and dated 07-01-2022 below.  My form starts off with only one table which has a button that creates another blank table.  I am going to create another button, which the user will click that will create a table that will have some of the same entries that were chosen in the first table. This is because I do not want the user to have to enter the same entries in the subsequent tables that are created.  I would like the initial entries to be "global" or something similar to the global affect when the new table or tables are created by clicking the new button.  Is this possible?

 

Your script in the click button of your example lists:

var h= event.target.getField("form1.Table1.Row1.Cell3");
form1.Table2.Row1.Cell3.rawValue = form1.TextField1.rawValue;

 

Your example starts off with two tables instead of one.  

 

Avatar

Level 5

Hello @islandgirl23 

I think you need to be more clear on what you try to achieve.

What's for sure is that the form will not "create" tables. it can show a table, or add an occurrence of a repeating subform that would include a table... things like that.

 

Here is a scenario:

the form includes a first table1 where one column contains dropdown lists; another column has a button to show a table2 where a field is calculated to equal the value of the dropdown field of the clicked row.

there can be as many instances of table 2 as there are rows in table 1.

See form here

Is this what you are trying to achieve? 

 

Avatar

Level 6

Good day,

This is almost what I want to achieve.  Please see the link https://drive.google.com/file/d/1IK3MyPMY2CpvX0jpNDfLPmwbBUToKWjb/view?usp=sharing .  I have two buttons with a "+" and "-".  Which works perfectly...it "adds" or "removes" a whole new blank table.  The user will enter as much information as needed into the table.  There will be times when an entry in the next table will be the same entry that was in the previous one, like the name. I would like the user to click the "similar" button which would add a whole table like the "+" button but keep some of the entries of the previous table.  The similar entries kept will be predetermined.  The user can then enter whatever is not similar.  If the next table does not have any similar entries, the user will click the "+" button and start from scratch.  So, I will need some type of script entered into the "similar" button to accomplish this.  Your help is greatly appreciated.

Avatar

Level 5

I played a bit with your form. 
since it does not look like you are using the features of a table, I just moved the fields into a repeatable field. 
anyway, I hope this is what you intended. The way to repopulate the new Card is to copy the fields’ value from the “clicked” instance into the new instance, using the resolveNode function.

link to the form

Avatar

Level 6

This is great!  One question...I see that the "Table" is no longer listed. How did you move the fields into a repeatable field exactly?  

Avatar

Level 5

The subform is repeatable: see the binding tab of the object. 

Avatar

Level 6

I figured out how to move the fields by copying and pasting and it works great!. But I have different forms with this same format and I don't want to have to move the fields of each form in order to make them work.  Some have more than 8 fields. Can I accomplish the same thing with the "Table" in place instead of moving the fields into repeatable fields?  

Avatar

Level 5

Yes, I wanted to point out that the data structure of your form was (unecessarily?) complex ... but you absolutely can achieve the same thing with repeatable tables. 

In your form you would go with something like

var sTargetNew = "cardssubform.Table1[" + nNewCardIndex + "]";
this.resolveNode(sTargetNew).Row1.type.rawValue = this.parent.parent.parent.Row1.type.rawValue;

this.resolveNode(sTargetNew).Row2.NAME.rawValue = this.parent.parent.parent.Row2.NAME.rawValue;

etc.

Avatar

Level 6

This works perfectly!  Thanks.  Maybe you can help me with my next question.  In one of my forms, I have a drop down box that is not visible until you check another box.  The problem is that when I add another "table", the drop down field selection is not copied to the next "table" when I click the "similar" button.  Can you help me with that?  

Avatar

Level 5

should the new table still have the dropdown list, and assign the value (i.e. "Ford"), or do you only need the value, not the dropdown list?

 

Avatar

Level 6

Yes, the new table should have the dropdown list, and assign the value.