javascript to select a textbox on a different section
Good afternoon.
I'm looking for the cod that will input data from one section to another section's textbox ones the user clicks on a button.
Can this be done in Agilepoint?
Kind regards
-
Morning Jason.
I'm capturing data on section 1, called the Input. This captured data is the user's name, age, address etc.
Once the user clicks on the designated button, this data is compiled into a single string of data which must be listed on the second section, named Records, into a textbox.
I need the data in the textbox to be a continues list, not overwriting the previous entry with a number the increases for each entry, i.e. 1, 2, 3, at the start of each string entry respectively.
Example of the string output to appear in the records section:
1. John Doe // 35 // 362 Black and grey Street //
2. Jane Doe // 32 // 4885 Purple Road //
Any help will be greatly appreciated.
-
Hello,
It appears this information is in a repeatable format. Have you tried utilizing the sub form control?
Although this solution appears to require some JavaScript, it isn't necessarily required. I created a similar format using a sub-form control which deals with repeatable format and formula controls.
For example here is the sub-form gathering the information in the Input section. The records field is a formula control that is concatenating it all together into 1 string:
I then take this information and can apply it to another sub-form in the Records section that is taking the row of each Input record and capturing it for each row. See image below.
Let me know if this helps!
Thanks,
Jason Wells
-
Good morning, Jason.
Thank you for the help.
This could indeed work, however due to specific requirements, I need to have the records appear on another section.
Is there javascript code to call a textarea on another section and input data into it?
I appreciate the help.
Kind regards
-
Hello,
Thanks for getting back to me!
Yes, it can be done. My solution above is just the approach that we take because AgilePoint as the codeless architecture framework allows for it to all be done without coding.
The code below isn't a perfect solution because of input error, you may need you to restarted the form entries, that is why I suggested the sub-form approach. Here is the JavaScript:
function concatDataStrings() {
let rowNumber;
let name;
let age;
let address;
let textArea;
eFormHelper.getFieldValue({ fieldId: 'Name' }, function(r) {
name = r.data;
eFormHelper.getFieldValue({ fieldId: 'Age' }, function(res) {
age = res.data;
eFormHelper.getFieldValue({ fieldId: 'Address' }, function(res2) {
address = res2.data;
eFormHelper.getFieldValue({ fieldId: 'HiddenRowNumber' }, function(res3) {
rowNumber = res3.data;
eFormHelper.getFieldValue({ fieldId: 'TextArea1' }, function(res4) {
if(res4.data == '') {
textArea = rowNumber + ' // ' + name + ' // ' + age + ' // ' + address;
} else {
textArea = res4.data + '\r\n' + rowNumber + ' // ' + name + ' // ' + age + ' // ' + address;
}
rowNumber++;
eFormHelper.setFieldValue({ fieldId: 'TextArea1', value: textArea }, function(res5) { console.log(res5); });
eFormHelper.setFieldValue({ fieldId: 'HiddenRowNumber', value: rowNumber }, function(res6) { console.log(res6); });
});
});
});
});
});
}You'll have to add a hidden number box control to track the count of the list. that is what you see in the code above. Make sure this number box control default value is 1.
Here is the configuration to add to the button control to initiate this:
And here is the output, in this example it is on the same section to show both in 1 screenshot.
Thanks,
Jason Wells
Please sign in to leave a comment.
Comments
8 comments