I have been stuck here for hours now. I need to get what value is selected in the dropdown after button clicked.All the rows are dynamically generated like this image.
I can get the child node and the html but can't get the selected value. My code so far.
var parent_element=e.parentElement.parentElement.parentElement.previousSibling.previousSibling.previousSibling.previousSibling;
var selected_element = parent_element.childNodes[1].getElementsByClassName('selectpicker');
console.log(selected_element);
Html stucture. Any help will be appreciated. Thanks in advance
<div class="col-md-12 neighbourhood-data neighbour-2">
<div class="row">
<div class="col-md-2">
<select name="" class="selectpicker form-control" data-live-search="true">
<option value="">--Select One--</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
<option value="4">Four</option>
</select>
</div>
<div class="col-md-1">
<input type="text" class="form-control" placeholder="Distance">
</div>
<div class="col-md-8">
<div class="row">
<div class="col-md-2">
<button type="button" class="btn btn-info" onclick="getDistanceLocation(this)">Get distance from google</button>
</div>
<div class="col-md-10">
<div class="row text-center">
<div class="col-md-2">
<input type="checkbox" checked="checked">
</div>
<div class="col-md-2">
<input type="checkbox">
</div>
<div class="col-md-2">
<input type="checkbox">
</div>
<div class="col-md-2">
<input type="checkbox">
</div>
<div class="col-md-2">
<input type="checkbox">
</div>
<div class="col-md-2">
<input type="checkbox">
</div>
</div>
</div>
</div>
</div>
<div class="col-md-1">
<button type="button" class="btn btn-danger neighbourhood-remove-button">Remove</button>
</div>
</div>
</div>