Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
How to show/hide an input based on the selected item in another drop down list in .net core 2.1 MVC

I have this drop down list:

<div class="form-group" id="businessEntitiesIdsLegal">
    <label asp-for="BusinessEntityTypeId" class="control-label col-sm-4 col-lg-3" asp-show-required-charachter="true">Some label</label>
    <div class="col-sm-5 col-md-4 col-lg-3">
        <select asp-for="BusinessEntityTypeId" id="BusinessEntityTypeId" asp-items="Model.BusinessEntities" class="select2 select-block-level search">
            <option value="@BaseViewModel.NotSelected">Choose something</option>
        </select>
        <span asp-validation-for="BusinessEntityTypeId" class="text-danger"></span>
    </div>
</div>

and I would like to handle if its selected item with value=2 then to show this div (and also if item get changed, to hide the div):

@if(Model.BuyerTypeId == BuyerTypeEnum.Legal.Id)
{
    <div class="form-group" id="foobar">
        <label asp-for="Jbkjs" class="control-label col-sm-4 col-lg-3"></label>
        <div class="col-sm-5">
            <input asp-for="Jbkjs" type="text" class="form-control" maxlength="5">
            <span asp-validation-for="Jbkjs" class="text-danger"></span>
        </div>
    </div>
}

How can I achieve this?

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!