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

Question

Question

Get this row drop down value

asked on June 15, 2015 Show version history

I'm currently trying to get a drop down value from a table. The table will have a different value from the drop down in each row. I currently have the calculation working for each row though I would like to get the value or the text from the drop down value that is selected. I currently have something like this:

$(this).find('.dropdown:selected').val()

I was wondering if my syntax is correct.

Any help would be appreciated thanks!

0 0

Answer

SELECTED ANSWER
replied on June 16, 2015

I didn't find possible place for dropdown field value in your code.

If you want to use the value inside the each function, add custom css class "dropdown" to the dropdown field and use "$(this).find(".dropdown select").val()" where you want to use the dropdown field value.

2 0

Replies

replied on June 15, 2015 Show version history

If you want to get the value of a dropdown field, there is no need to find selected option, using val() would be enough:

$("select").val()

However there can be multiple select on a row, so I would suggest that you set custom css class on the drop down field, like this ("dropdown" is the custom css class):

$("tr").each(function(i){
  console.log($(this).find(".dropdown select").val())
})

 

2 0
replied on June 16, 2015

My current loop is similar to that though my syntax is as follows:

$('.cf-table-block tbody tr').each(function () {
            eachCost =  parseNumber($(this).find('.eachCost input').val()); 
            quant = parseNumber($(this).find('.quant input').val());
            });

With what I currently have would I be able to line 2 of your code within mine and have it work correctly?

0 0
SELECTED ANSWER
replied on June 16, 2015

I didn't find possible place for dropdown field value in your code.

If you want to use the value inside the each function, add custom css class "dropdown" to the dropdown field and use "$(this).find(".dropdown select").val()" where you want to use the dropdown field value.

2 0
replied on June 18, 2015

I attempted this and it did work. The only issue is that it only works when I click on and then out of an input field from the table and/or row. I am doing this with a blur and input trigger for the function. This is only effected in internet explorer. This works in firefox and chrome. Are there any suggestions to have it trigger in IE as well when the drop down is selected?

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

Sign in to reply to this post.