Skip to main content
Hoey
Known Participant
November 19, 2020
Answered

Help w/ pulling data from one textbox to another textbox based on a separate dropdown box/value.

  • November 19, 2020
  • 1 reply
  • 827 views

I apologize in advance if this is confusing. 

 

So I have a dropdown ("dh1ZoneDD") - with options: 1, 2, 3, 4

I have a textbox ("z1GPP1") that will receive/display the info based on the selection of the DD.

And I have 4 textboxes that will have some calculated data (we can call these "GPP1", "GPP2", "GPP3", "GPP4") if the dropdown selection is 1 - "z1GPP1" will display the value that is in "GPP1".

 

I've tried a few approaches when it comes to coding this solution and I can't get it to work beyond displaying the first value from GPP1 when the DD choice is 1. Any bit of help is greatly appreciated!

 

<This Code is placed in "z1GPP1">

var z1 = this.getField("z1GPP1").value;
var z2 = this.getField("z2GPP1").value;
var z3 = this.getField("z3GPP1").value;
var z4 = this.getField("z4GPP1").value;

if (event.target.value = 1) {
    this.getField("dh1ZoneGPP1").value = z1;
} else if (event.target.value = 2) {
    this.getField("dh1ZoneGPP1").value = z2;
} else if (event.target.value = 3) {
    this.getField("dh1ZoneGPP1").value = z3;
} else if (event.target.value = 4) {
    this.getField("dh1ZoneGPP1").value = z4;
}
This topic has been closed for replies.
Correct answer try67

And change these lines:

if (event.target.value = 1) {

To:

if (event.value == "1") {

1 reply

Bernd Alheit
Community Expert
Community Expert
November 19, 2020

You should use a validation script at the dropdown list.

Hoey
HoeyAuthor
Known Participant
November 19, 2020

Would I use similar code for that? 

 

I've never used a validation script before. I'll look up the documentation on it.