0

Please suggest if below works as i want to hide a drop down value based on other drop down value selection , but it is not working as expected.

var dropdown1 = $(":input[title='Engagement Type']");

if(dropdown.find("option[value='Tracking Number request']")==true)
{
  dropdown1.find("option[value='CR(Change Request)']").remove();
  }
0

3 Answers 3

1

You can write the below change event of the first drop-down and hide the option of the second drop-down based on the selected value of the first drop-down.

Drop-down 1's ID = dropdown1

Drop-down 2's ID = dropdown2

   $("#drop-down1").change(function(){
            var selectedValue = $(this).children("option:selected").val();
            if(selectedValue === "Tracking Number request")
            {
                $("#drop-down2 option[value='CR(Change Request)']").remove(); 
            }       
    });
4
  • Hi how can i get Id for these columns? sorry but i am not aware much of it Sep 3, 2020 at 7:59
  • Hi @Divya Sharma, I tried this too it is not working :( Sep 3, 2020 at 8:35
  • Are you getting the selected value of the first drop-down as expected? Also, does it go inside the 'if' condition? Also, which error are you facing exactly? Sep 3, 2020 at 9:36
  • Nope it is not foinf inside if condition and the value is not getting hidden. did not get any error also Sep 8, 2020 at 5:39
0

you should just edit the condition in your if. Just use as below

if(dropdown.find("option[value='Tracking Number request']"))
{
  dropdown1.find("option[value='CR(Change Request)']").remove();
}
1
  • Hi , yes i tried it , but the value "change request" is getting removed irrespective of other column drop down value selection. I have two drop down fields , based on first drop down selection value - "Tracking number request" the second column drop down value "CR" should be removed . Note : I have multiple values in other drop down values , the value CR should not be shown only for "tracking number" Sep 3, 2020 at 6:53
0

Try this:

<select title='Field A'>
  <option key="A">A</option>
  <option key="B">B</option>
  <option key="C">C</option>
</select>

<script src="https://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"> </script> 
<script type="text/javascript">
         $(document).ready(function () {
            $("select[title='Field A']").change(function () {
           
                if ($("[title='Field A'] option:selected").text() == "A") {
                    $("[key='C']").hide()
                }
                
            });
        });

</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.