You are viewing limited content. For full access, please sign in.

Question

Question

Accessing values field from drop-down list

asked on June 2, 2017 Show version history

I have a drop-down list on a form, with hard-coded values in both the "Choices" box and the "Values" box.  I would like to be able to access data from both of these boxes, so that when I store form data onto a template, I can retrieve data from both the "Choices" box and the "Values" box.

Example:  the drop-down list is defined as such:

In the Choices box are a list of entities, and in the Values box is the email address for each entity.  The checkbox "Assign values to choices" is checked, and the checkbox "Append choices to lookup results" is not checked.

What I need to be able to do is retrieve the selected "entity name" from the Choices box and put that into a field on a template, and also retrieve the "email address" for that same selected entity and put that into another field on the same template.

Can this be done?

0 0

Replies

replied on June 4, 2017 Show version history

When drop down field has "assign values" configured, the submitted field value would be value instead of choice text. So to save both choice text and value, you can use custom script to save selected option text to a hidden field. The script could be like this:

$(document).ready(function(){
  $('#Field1').change(function(){
    $('#Field2').val($('#Field1 option:selected').text());
  })
})

Field1 is id for drop-down field while Field2 is id for the hidden field.

3 0
replied on May 8, 2020

This was a huge help to me, but I had to make one tweak to get it to work for me:

 

$(document).ready(function(){
  $('#Field1').change(function(){
    $('#Field2 input').val($('#Field1 option:selected').text());
  })
})

 

0 0
replied on May 8, 2020

This was a huge help to me, but I had to make a tweak to get it to work:

 

$(document).ready(function(){
  $('#Field1').change(function(){
    $('#Field2 input').val($('#Field1 option:selected').text());
  })
})

 

You are not allowed to follow up in this post.

Sign in to reply to this post.