Autopopulate text field based on drop down menu in repeating table

goodhvnting 10-09-2018

Hello,

First off, apologies if this question has already been asked/answered, but I wasn't able to find a thread that had my specific problem.

Background:

I have a table that will dynamically grow when the User presses an "+" button. In my table I have a drop down box that auto populates a text box based on a Users specific selection. This is the code that I used:

form1.page1.subform1.Table1.Rows.ItemDescription::exit - (JavaScript, client)

form1.page1.subform1.Table1.Rows.WarehouseCode.rawValue = form1.page1.subform1.Table1.Rows.ItemDescription.rawValue;

The above code works well however, it only works for the first row and not any subsequent rows that are added when the User selects the "+" button.

Question:

What script am I missing that will allow the "WarehouseCode" value to auto populate when a User adds more rows to the table?

Much appreciated! This community has already been so helpful to me especially when I am not a programmer or expert by any means

Mark Solution

Are these answers useful?
Help other community members by marking useful answers as accepted.

Accepted Solutions (0)

Answers (3)

Answers (3)

MinusZero 11-09-2018

I have experimented with doing as you described. The only difference i see in your initial code is that I put the dropdown event code in change rather than exit.

This is what i did to try it out:

1569737_pastedImage_2.png

1569739_pastedImage_4.png

1569740_pastedImage_5.png

I also specified values for the dropdown list

1569741_pastedImage_6.png

When i select a dropdownlist item, it returns the value in the textfield. It doesnt matter how many rows are added, each is separate to the other.

1569742_pastedImage_7.png

goodhvnting 11-09-2018

Hello!


Thanks so much for replying!

Your understanding is close but let me clarify further for you.

I want each row's WarehouseCode to auto populate based on the Users ItemDescription dropdown selection. So I don't want it to repeat what was selected in Row 1; it will be empty until someone selects an ItemDescription and then based on that selection it will call up the associated WarehouseCode. Right now, the code I am using does that for the first row, but it will not do that for any subsequent rows added.

Is that more clear?

Thanks again for your help! I really appreciate it. Learning lots here.

MinusZero 10-09-2018

Hi,

If i am understanding right. You want each row's WarehouseCode to be the same as the one selected in the dropdown on the first row?

If this is the case.

In the intialise event for the WarehouseCode add:

//the code will still execute when the form loads, but nothing is there so it doesnt matter

//each new row will get the value in the ItemDescription dropdown and add it to the WarehouseCode TextField on each new row when the add button is clicked.

//FYI, the [0] in the code represents the first instance (first repeating row of the table). Each time you add a row, the raw value from the first row is used. Each row gets a new instance reference so you can target other rows if needed. Table row 2 is instance [1], row 3 is [2] and so on.

this.resolveNode("$").rawValue = this.resolveNode("form1.page1.subform1.Table1.Rows[0].ItemDescription").rawValue;