I have two drop down menus where I want the options in the second drop down menu to be hidden depending of which option is selected in the first drop down menu. I have found some examples in google for this but the problem is that because I am too deep in my coding, I do not want to risk creating new functions and using jquery and etc from scratch. So what I want to know if someone can implement into my code the way this can be achieved by creating one example of this which is below: Show If optionDrop (Drop Down 1) value = "ABC", then numberDrop (Drop Down 2) options will shows "", "1", "2" and "3" but hides "4". Below is javascript code which is relevant to this question (there is more to this code but don't need to show it for this question): Html code that shows drop down menus: How to hide values in dropdown in javascript?Take two: function getDropDown() { var optionDrop = document. getElementById("optionDropId"); var numberDrop = document.
How do I hide a drop down list in HTML?We use <select> and <option> elements to create a drop-down list and use disabled attribute in <select> element to disable the drop-down list element.
How do I change a selection based on another dropdown?We want to change the selects options based on other dropdowns so we will follow the below steps.. Create a state variable that is initially null or undefined.. Create different arrays for different dropdowns.. Create a local variable say type that will hold any of the array based on the dropdown selected.. How do you enable disable a dropdown based on value in another dropdown in jquery?val() == "<yourValue>") { $("#ddl2"). prop("disabled", true); } else $("#ddl2"). prop("disabled", false); }); }); The above code will disable the "ddl2" dropdown on select of a particular value in first dropdown.
|