Issue
<div class="form-group">
<label for="repId">REP ID</label>
<select name="item" class="form-control " style="font-weight: bold;" ng-model="idDropdown">
<option value="{{item}}">Select REP ID</option>
<option ng-repeat="item in columnData" value="{{item}}">{{item}}</option>
</select>
</div>
I have tried to get the value selected from dropdown list to Javascript. But I am getting undefined. Below is the code which I have tried in Javascript to read the item value.
var repId = $('#item').val();
Solution
As you have a label
element with a given for='repID'
where repID
should be the ID of the input element that the label describes then you can add the ID to the select menu as per the following.
The change
handler is there simply to illustrate it in action
$('#repId').change(e=>{
alert(e.target.value)
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="form-group">
<label for="repId">REP ID</label>
<select id='repId' name="item" class="form-control " style="font-weight: bold;" ng-model="idDropdown">
<option value="{{item}}">Select REP ID</option>
<option ng-repeat="item in columnData" value="{{item}}">{{item}}</option>
<option>Smurf
<option>Womble
<option>Clanger
<option>Moomin
<option>Muppet
</select>
</div>
Answered By - Professor Abronsius
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.