Click here to Skip to main content
16,011,949 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
XML
<script type="text/javascript">
    function showHideDivs(elem) {
        var divsObj = document.getElementsByClassName('showHideDivs');
        for (i = 0; i < divsObj.length; i++) {
            divsObj[i].style.display = (divsObj[i].id == 'd' + elem.value) ? 'block' : 'none';
        }
    }
</script>
  <div class="editor-label">
            @Html.LabelFor(model =&gt; model.custMain.CTypeID)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model =&gt; model.custMain.CTypeID, (IEnumerable<SelectListItem>)ViewBag.ClientType, "Select Client Type", new { @class = "showHIdeDivs", @onchange = "showHideDivs(this)", id = "cid" })
            @Html.ValidationMessageFor(model =&gt; model.custMain.CTypeID)
        </div>
 <div class="showHideDivs" id="d1"></div>

how can we use show and hide div using dropdownlist in edit view?
Posted
Updated 1-Aug-12 0:14am
v2

1 solution

Any way you like. You have written code here, does it work ? What do you WANT it to do ? How does the selection of a drop down list define the way you want the divs to show ?
 
Share this answer
 
Comments
sajan064 1-Aug-12 6:25am    
ya it works to show and hide div?
but i am unable to use this in edit view as the data has been posted from controller to view?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900