Vitalikssssss Posted December 5, 2019 Report Share Posted December 5, 2019 Hi everyone, How can copy the text from the selected drop-down element to the text field? Thanks for looking into. Regards, vitalikssssss Quote Link to comment Share on other sites More sharing options...
Alison Posted December 5, 2019 Report Share Posted December 5, 2019 Hi @Vitalikssssss, You should add two text fields to the Selected fields on the Submission form and one of them make a Dropdown form element. After that create a Header and Footer element and past the following code into the footer after disabling HTML edotir: <script> document.addEventListener("DataPageReady", function() { let dropdown = document.getElementById('InsertRecordname'); let textfield = document.getElementById('InsertRecordnumber'); let change = function() { textfield.value = this.options[this.selectedIndex].value; }; if (document.addEventListener !== undefined) { dropdown.addEventListener('change', change, true); } else if (document.attachEvent) { dropdown.attachEvent('onchange', change); } else { dropdown.onchange = change; } }); </script> InsertRecordname and InsertRecordnumber are the ids of the text fields elements where InsertRecordname is set to the Dropdown form element. Vitalikssssss 1 Quote Link to comment Share on other sites More sharing options...
kpcollier Posted March 17, 2021 Report Share Posted March 17, 2021 What if there are two dropdowns? I have two virtual fields with the same datasource - but one is filtered and one is not. I have a checkbox to hide one of the virtual dropdowns, so only one of them will get a value. In example, if the checkbox is checked, then Virtual1 Dropdown is displayed and Virtual2 dropdown is hidden. If the checkbox is unchecked, vice versa. How would I add the check to see if Virtual1 dropdown or Virtual2 dropdown has the value? Any help is appreciated. Quote Link to comment Share on other sites More sharing options...
TellMeWhy Posted March 17, 2021 Report Share Posted March 17, 2021 45 minutes ago, kpcollier said: What if there are two dropdowns? I have two virtual fields with the same datasource - but one is filtered and one is not. I have a checkbox to hide one of the virtual dropdowns, so only one of them will get a value. In example, if the checkbox is checked, then Virtual1 Dropdown is displayed and Virtual2 dropdown is hidden. If the checkbox is unchecked, vice versa. How would I add the check to see if Virtual1 dropdown or Virtual2 dropdown has the value? Any help is appreciated. If you're hiding it, you don't need to, you just want to pass the dropdown value if it's changed. Just do script for both, if a dropdown is hidden, they will not be changed anyway, so, the script should not fire. For example I have a dropdown with id cbParamVirtual1 document.getElementById('cbParamVirtual1').addEventListener('change', function() { document.getElementById('InsertRecordTitle').value = document.getElementById('cbParamVirtual1').value; }) for your 2nd dropdown, if it's cbParamVirtual2, just do the same, and rename the Virtual1 document.getElementById('cbParamVirtual2').addEventListener('change', function() { document.getElementById('InsertRecordTitle').value = document.getElementById('cbParamVirtual2').value; }) kpcollier 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.