how to get selected td row value in javascript?

Hamza Qureshi

i want to select selected row value on button on click for this in select option i have name="product_id" and class="productid" i want value of product_id so i have this code

                <td>
                <select class="productid" name="product_id" >
                @foreach($findadminproducts as $a)
                <option value="{{ $a->id }}" >{{ $a->name }}</option>
                @endforeach
                </select>
                    <button onclick='linkproduct(this);'>Use Location</button>
                </td> 

method i tried in js

<script>
   function linkproduct(button){
     var b = $(this).closest("td").find('select.productid').text();
     console.log(b);
}
</script>

but it gives empty value or if i use .val() then it gives undefined

Ostaad g

try this

var b = $(button).closest("td").find('select.productid').val();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Get the column value <td> from a selected row <tr> by the class Attribute

How to get value of a <td> onclick to an other <td> of a same row?

how to get value of selected row in aspxgridview devexpress

How to get column value of selected row

How to get Table td value on span click after that remove that row

How to get the value of data selected in datalist in Javascript?

how to get value of selected datalist by javascript on change

JavaScript : How to get selected dropdown value?

how to get value in <td>

How to get selected checkbox table row with each td data attributes to array objects?

get td jstl value by javascript

jquery datatable - how to get a value from a selected row

How to get data-value from selected row datatables

How can I get the selected row's value of a qtablewidget in PyQt?

How get the value of a cell in a selected row (shiny DT library)

How to get selected row value from C1FlexGrid

How to get the String value of selected row in a UIPickerView in Swift 3?

How to get value from selected row of GridPanel? [Ext.Net]

How to get the column value of the selected row in wpf listview

How can i get the textbox value in selected row in gridview

JQuery-getting th value of selected td in same row & th vertically up from same selected td

how to Get the value of TD in a foreach loop using javascript?

How to get second td value of tr in a table using javascript or typescript

how to get value from table td using javascript

How do I get the selected row in Gridview in Javascript or JQuery

Cannot get value of a first TD in current row

get all td value of same row by jquery

How to get td innerHTML per row and then set div css per row based on this value

Get value of a <td> onclick to an other <td> of the same row with Angular