Copy link to clipboard
Copied
New here, so I apologize if I don't follow proper procedure. Thank you, Thom Parker, for your assistance and I apologize for the delayed check on correct answer from previous question. I have another question regarding my project. Attached are two pages from my project.
Goals:
Document:
I am not having any luck with the script below to populate name based on listed position. Suggestions?
////Script Name: ICS-205A drop
function DoNameReferencePosition()
{
var cRowName = event.target.name.split(".").shift();
var fieldB = this.getField(cRowName + ".205A DropA").value;
if (fieldB == this.getField("Row1.Position").value) event.value = this.getField("Row1.Name").value;
else if (fieldB == this.getField("Row2.Position").value) event.value = this.getField("Row2.Name").value;
else if (fieldB == this.getField("Row3.Position").value) event.value = this.getField("Row3.Name").value;
else if (fieldB == this.getField("Row4.Position").value) event.value = this.getField("Row4.Name").value;
else if (fieldB == this.getField("Row5.Position").value) event.value = this.getField("Row5.Name").value;
else if (fieldB == this.getField("Row6.Position").value) event.value = this.getField("Row6.Name").value;
else if (fieldB == this.getField("Row7.Position").value) event.value = this.getField("Row7.Name").value;
else if (fieldB == this.getField("Row8.Position").value) event.value = this.getField("Row8.Name").value;
else if (fieldB == this.getField("Row9.Position").value) event.value = this.getField("Row9.Name").value;
else if (fieldB == this.getField("Row10.Position").value) event.value = this.getField("Row10.Name").value;
else if (fieldB =="") event.value="";
}
Copy link to clipboard
Copied
Change the value of any field and then check the JS Console. There are errors in your code.
Copy link to clipboard
Copied
The code is not correct. What is the if statement ".Position" equals then statement ".Name" using ".205A DropA” as the reference is recommended?
Copy link to clipboard
Copied
It appears that you are attempting to implement somewhat complicated functionality. In this case, copying data from one table into another based on a dropdown selection. But there is obviously other complex behaviors as well, such as filling in the items in the dropdown. These should really come from the first column in the first table, not the "ListItems" field.
In order implement this complex behavior, and to fix the code on your form you'll need to do a couple of things. First, it is a really good idea to spend some time learning core JavaScript. Any time spent up front leaning the basics will be paid back many times. Second, you need to fix the easy errors before asking us for help. For example, there are many "this.getField()" calls that specify non-existant field names. Clear these up first. Next, you've done a good job of naming the fields in the tables, use these names make the coding simpler. This is the type of thing you should be asking us about.
Copy link to clipboard
Copied
Thank you for the feed back. I'll go back and try to learn more.