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

Question

Question

Display multiple records in one text box

asked on October 1, 2015

I have linked an SQL table to a user number and need to retrieve the list of associated items.  For example -

For User number 1, bring in all the names associated with it.  There could be up to 50 names for each user number.  I was able to see the list in a dropdown but would like it in a text box.

 

Thank you.

Shalini

0 0

Replies

replied on October 1, 2015

Hi Blake

I'm looking for something to just list the values in that second column, not necessarily concatenate two fields.  So ideally looks like this -

 

 
     
     
     
     
     
     
     
     
     

 

Book1.xlsx (8.38 KB)
0 0
replied on October 2, 2015

Here is a proof of concept that you should be able to adapt to your form.

I have configured a form with a single line field (input), a drop down list (select), and a multiline field (textarea). My input uses the CSS class "state". My textarea uses the CSS class "neighborhoodtextarea". My drop down list has the id Field3. I've configured a lookup so that whatever I enter in as the state, it will populate the drop down with the various neighborhoods that are in that state. My Javascript will then take the values from the select element and place it into the textarea.

$(document).ready(function () {
  
  $('.state input').on('change', function () {
    setTimeout(function() {
      $('.neighborhoodtextarea textarea').val('');
      $("select#Field3").each(function() {
        var str0 = $(this).html().replace(/\<option\>\<\/option\>/g, '');
        var str1 = str0.replace(/\<option\>/g, '');
        var str2 = str1.replace(/\<\/option\>/g, '\n');
        $('.neighborhoodtextarea textarea').val($('.neighborhoodtextarea textarea').val() + str2);
      });
    }, 100);
  });
  
});

The resulting form submission looks like the following (I just typed in "california" into the input field and then tabbed to the next field):

And you can see it does match up with what's in the drop down

Something to note is that when a drop down list is populated from a lookup, there are no actual values associated with the option elements. That's why I have to manipulate the HTML and strip away the option tags to get the strings between them. Another thing is that I added a tenth of a second delay to give the lookup time to populate the drop down field before the JS runs.

Also, while I didn't explicitly hide the drop down list, you could do so.

0 0
replied on October 5, 2015

Not quite working, but I think Im really close - can you see any glaring error

(Input is UserNo (is it case sensitive?)

select is Restricteddropdown (do I include the #?)

textarea is RestrictedList)

 

 

$(document).ready(function () {
 
$('.UserNo input').on('change', function () {
setTimeout(function() {
 $('.RestrictedList textarea').val('');
 $("select#Restricteddropdown").each(function() {
  var str0 = $(this).html().replace(/\<option\>\<\/option\>/g, '');
  var str1 = str0.replace(/\<option\>/g, '');
  var str2 = str1.replace(/\<\/option\>/g, '\n');
   $('.RestrictedList textarea').val($('.RestrictedList textarea').val() + str2);
  });
 }, 100);
 });
 
});

0 0
replied on October 5, 2015

In my Javascript, where I used

$("select#Field3").each(function() {

you'll need to replace #Field3 with the actual id associated with your drop down field. You'll notice in the screenshot from my earlier post, the drop down field had an id of q3 so that's why my JavaScript referenced #Field3. You'll need to do the same but using the id that's assigned to the drop down field in your form.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.