Jump to content

Add a value from the Dropdown field to the Text field


Recommended Posts

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.image.png.b2a10ee710e226f84a318d9f11894b2a.png

  

image.png

Link to comment
Share on other sites

  • 1 year later...

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.

Link to comment
Share on other sites

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;
})

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...