My aim is:
- If I type a value bigger than 60, then I would like the option "Long" to be selected.
- If I type a value less than 60, then I would like the option "Short" to be selected.
With help of of jQuery, I would like for "result" to be automatically changed given the field "value"
I have a form, contains an input integer field, with id "value", and form has a option field with id "result".
Below is my try, but it does not work.
Thanks for your input.
var value = $('#value');
$(value).change(function() {
debugger;
if (Number($(this).val()) > 60) {
$('#result').prop('value') = "Long";
}
if (Number($(this).val()) < 60) {
$('#result').prop('value') = "Short";
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<label for="value" class="col-form-label col-sm-4">Value</label>
<div class="col-sm-7"> <input type="number" name="value" class="numberinput form-control" id="value"> </div>
</div>
<div><i>Result:</i></div>
<div id="result" class="form-group row">
<div class="col-sm-12">
<select name="result" class="select2 form-control" style="width: 100%;" id="result">
<option value="Long">Long</option>
<option value="Short">Short</option>