Topic: Material Select Set selected value

hetal free asked 7 years ago


I have Material Select List and I want to set selected value by using javascript or JQuery but material select list not showing that value

Rafael Pujol free answered 6 years ago


var element = $("#youselectId")

element.prevAll('.select-dropdown').children('li:eq(2)').trigger('click');

you can  remplace the number 2 with the item id that you want select

var changeSelectPickerValue = function (id, value) {

var element = $("#" +id)
element.prevAll('.select-dropdown').children('li:eq('+value+')').trigger('click');

}


Furey free commented 6 years ago

$(#element_id)prevAll(‘.select-dropdown’).children(‘li:contains(‘+value+’)’).trigger(‘click’);

dejan.mauer pro answered 7 years ago


Great! This solved my issue.

It's possible. Here you can find a solution

dejan.mauer pro answered 7 years ago


I am struggling with the same problem... I have this HTML:
<div class="col-md-4 input-field">
	<select id="selectDiscount">
		<option id="selectDiscountNone" selected value="None">Not specified</option>
		<option id="selectDiscountMoney" value="Money">in money</option>
		<option id="selectDiscountPercent"value="Percent">in percent</option>
	</select>
</div>
How it is possible to select, for example, second option as with JavaScript?

Michal Szymanski staff answered 7 years ago


Can you provide your sample code?

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags