javascript - Input type "range" - Set dynamic range -
i'm looking way set minimum value of input of type range
equal value of specific field.
at moment, have this:
these shown in modal window
<div class="form-group"> <label asp-for="numdevices" class="col-md-2 control-label"></label> <div class="col-md-10"> <input id="numdevices" type="text" asp-for="numdevices" class="form-control" /> <input id="getnum" type="range" max="10" step="1" onchange="fetch()" class="form-control" /> </div> </div>
and current js:
<script> function getminimun() { var minimun = document.getelementbyid("numdevices").value; var shareminimun = number(minimun); document.getelementbyid("getnum").min = shareminimun; } </script>
questions: need call getminimun() function input of id: "getnum". how can that? there onload option? onload="getminimun()"
is correct i'm proposing? can made better?
for curious, fetch()
function:
<script> function fetch() { var = document.getelementbyid("getnum").value; document.getelementbyid("numdevices").value = get; } </script>
solved this:
since i'm using modal window show these fields added following code in order execute javascript once modal opens.
<script> $(document).ready(function getminimun() { $('#modal-action-machine').on('shown.bs.modal', function () { var minimun = document.getelementbyid("numdevices").value; var shareminimun = number(minimun); document.getelementbyid("getnum").min = shareminimun; document.getelementbyid("getnum").value = shareminimun; }); }); </script>
it needed set value of "getnum" input type range particular case.
Comments
Post a Comment