Select an option when input change
I want to select an option when I insert a value into an input. Here's my HTML:
- <input type="text" id="point" />
- <select id="passed">
- <option value="2"> -- Choose --</option>
- </select>
And here is the JS:
- $(document).ready(function () {
- $("#point").change(function () {
- var val = $(this).val();
- if (val === 0 && val < 60) {
- $("#passed").html("<option value='0' selected='selected'>Not passed</option>");
- } else if (val >= 60 && val === 100) {
- $("#passed").html("<option value='1' selected='selected'>Passed</option>");
- }
- });
- });
Please help me to achieve this.