I have a form with 1 input and 1 select with options (example: 2500, 3000, 4000, 5000)
I need to be able to:
- Create an array for each options in the select
- When I enter a value in the input field (number)
- Determine between each select.value is the text.value
- Fake click on the select.value which is the "min" range.
Example :
- input =
2800
> Fake click onselection.option(2500)
- input =
3200
> Fake click onselection.option(3000)
Where it's tricky, that's the select has different value on each page.
At this time, to test:
<input min="0" max="7000" class="largeur" value="" type="number" placeholder="" required="">
<select id="longueur" class="" name="attribute_longueur" data-attribute_name="attribute_longueur" data-show_option_none="yes">
<option value="">Choisir une option</option>
<option value="2508" class="attached enabled">2508</option>
<option value="4785" class="attached enabled">4785</option>
</select>
$(".largeur").keyup(function() {
console.log('keyup');
$('#longueur option[value="2508"]').prop('selected', true); // Only to test fake click on value 2508
});
Thanks for the help!