Topic: Material select retrieve option value
Hi,I'm trying to retrieve the value of the options that I have specified for a material select input field. After a lot of trial and error and a lack of documentation about this topic I'm still not getting the wanted result.Snippet of my initialization:
<div class="col"> <div class="md-form mt-0"> <select class="mdb-select" id={{$id}}> @if(isset($options) && count($options) > 0) @foreach($options as $option) <option value="{{$option->id}}">{{$option->value}}</option> @endforeach @else <option value="INVALID">No options available for this user</option> @endif </select> <label>{{$label}}</label> </div> </div>
I would like to be able to get the value of the selected option in JQuery but I see no way to access this.Thanks in advance
Adam Stapleton pro answered 7 years ago
$('#select-id').val();This would get the option items individually from the select for you to do as you wish with.
$('#select-id option:selected)
Jakub Strebeyko staff answered 7 years ago
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- User: Pro
- Premium support: No
- Technology: MDB jQuery
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No