0
I am trying to enter some data in the select of my form, I am using mdl-select
The problem is I’m trying to enter a value but it just doesn’t work.
I would like the value searched in the database to be entered in select. what is wrong?
<!-- Simple Select -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://creativeit.github.io/getmdl-select/getmdl-select.min.css">
<script defer src="http://creativeit.github.io/getmdl-select/getmdl-select.min.js"></script>
<div class="mdl-textfield mdl-js-textfield getmdl-select">
<input type="text" value="" class="mdl-textfield__input" id="sample1" readonly>
<input type="hidden" value="" name="sample1">
<label for="sample1" class="mdl-textfield__label">Country</label>
<ul for="sample1" class="mdl-menu mdl-menu--bottom-left mdl-js-menu">
<li class="mdl-menu__item" data-val="DEU">Germany</li>
<li class="mdl-menu__item" data-val="BLR">Belarus</li>
<li class="mdl-menu__item" data-val="RUS">Russia</li>
</ul>
</div>
<script>
//Set value
$('#sample1').val('RUS')
</script>
Note that the RUS value disappears by clicking on another part of the screen.
– Vinicius
I couldn’t understand, it’s working normal.
– LeAndrade
The expected value for RUS is Russia, in addition to the some value of the screen. Analyzing in Chrome Dev Tools you can see that the value tag is empty.
– Vinicius