Skip to content Skip to sidebar Skip to footer

Conditional Dropdown Is Needed If The Option Is No Then Only The Other Should Appear If Not It Must Be Null

@**@

Solution 1:

I think what you are looking for is jquery. With this, you can check if the #son is set to "no" and then set another piece of code to show and hide. Here is a piece of code that should look a lot like what you want:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>

<body>
  <div class="form-group">
    <label asp-for="son" class="control-label">Son</label>
    <select name="son" id="son">
      <option value="none" selected="selected"> -- choose one --</option>
      <option value="yes">Yes</option>
      <option value="no">No</option>
    </select>
    <div id="father" style="display: none;">
      <label asp-for="father" class="control-label a">Father</label>
      <select name="father">
        <option value="none" selected="selected"> -- choose one --</option>
        <option>Signed SOW Awaited</option>
        <option>Onboarding in Progress</option>
      </select>
    </div>
  </div>
  <script>
    $("#son").change(function() {
      if ($(this).val() === "no") {
        $("#father").show();
      } else {
        $("#father").hide();
      }
    });
  </script>
</body>

</html>

JQuery might be a little intimidating at first, but I suggest just sticking to the basics like this. This is also pretty much all I know about JQuery.


Post a Comment for "Conditional Dropdown Is Needed If The Option Is No Then Only The Other Should Appear If Not It Must Be Null"