I’m using a button to grab select option values that are within the same row. If I were to add a function to the select dropdown, I get these values:
When I add another button to grab these values, I can’t quite get the same information. It looks like this:
The getValue is just the variable holding the information. If I do getValue[0], it grabs the 0: select#manufacturer_1… but I want to replicate the first image where it has all of those values at the base level.
<table>
<tr>
<td>
<select class="manufactor-selector-dropdown">
<option>Manufactor1</option>
<option>Manufactor2</option>
<option>Manufactor3</option>
...
</select>
</td>
<td>
<button>Select Values </button>
</td>
</tr>
</table>
javascript:
function(n) {
var getValue = $(n).parents('tr').find('td .manufactor-selector-dropdown');
var getSelectedValue = getValue.val();
}
2
Answers
It is quite difficult to understand your problem, could you please explain more.
I am partly guessing as to what your intended result is supposed to be. Maybe the following is helpful?
I changed your "function" quite a bit. It now looks for the parent element of the clicked button, then goes down and collects all options of the element with class "manufactor-selector-dropdown option" that is under a "td" element. with the jQuery method
.map()
I then extract all their values and convert the jQuery object into an array with.get()
.