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

Question

Question

Passing values into table dropdown

asked on September 30, 2015 Show version history

I'm looking to pass the values of two fields into a dropdown in a table. 

Here is the working code i have for passing those values into a dropdown outside of the table.

When replacing '#Field25' with #Field21(1)' nothing happens and when replacing it with '.droppy1' the class i gave to the dropdown field in the table it just adds another label under the field rather than add an item to the drop down list.

  //Set dropdown
    $('.test1').on('blur', 'input', fill0);
  	function fill0() {   
      //clear dropdown
      $('#Field25').empty();

      //append values
        var numbers = [$('#q5 input').val(), $('#q17 input').val()];
        var option = '';
        for (var i=0;i<numbers.length;i++){
           option += '<option value="'+ numbers[i] + '">' + numbers[i] + '</option>';
        }
        $('#Field25').append(option);
    };  

Any help would be greatly appreciated.

0 0

Answer

SELECTED ANSWER
replied on October 1, 2015

Hi there Casey,

You might have to select the drop down in the table a little differently by using something like:

$(".droppy1 select").append(option);

This should select the drop down's 'select' HTML tag from inside the table.

Cheers! Dan.

1 0

Replies

replied on October 1, 2015

Thanks a ton Daniel!

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

Sign in to reply to this post.