Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
There are one dropdown list and two textboxes(one is visible and two are not)On change of dropdown list to "In Between" option I have to show the two text boxes and the other textbox will be hidden
XML
<script src="/Scripts/jquery.jqGrid.js" type="text/javascript"></script>
<script src="~/Scripts/grid.locale-en.js" type="text/javascript"></script>
<link href="../../Content/ui.jqgrid.css" rel="stylesheet" type="text/css" />
<link href="../../Content/jquery-ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(function() {
        if ($("#dropDownRange").val() == 'In Between')
            $("#hideme").show();
        else
            $("#hideme").hide();
    });

</script>
<h2>
    Reports</h2>
@using (Html.BeginForm("Report", "Report", FormMethod.Post))
{
    <table style="font-size: small" width="100%">
        <tr>
             <td class="labels" align="center">
                     Select Range:
                 <select id="dropDownRange" name="dropDownRange" class="wpdodropdown"  style="font-size: small;margin-right: 10px;">
                 <option>Equals</option>
                 <option>Greater Than</option>
                 <option>Less Than</option>
                 <option>In Between</option>
                 </select>

                    <td width="auto" align="left">Date:
                        <input type="text" name="Date" />
                    </td>

        </tr>
        <tr class="hideme">
              <td width="auto" align="center"> From:
                  <input type="text" name="FromDate" />
              </td>
              <td width="auto" align="center">To:
                  <input type="text" name="ToDate" />
            </td>
 </table>
Posted
Updated 15-Oct-14 11:14am
v3

Modifying your jQuery side of things, you could do something like this:
JavaScript
$(document).ready(function(){
    $(".hideme").hide();
    $("#dropDownRange").change(function() {

        if ($("#dropDownRange").val() == 'In Between')
            $(".hideme").show();
        else
            $(".hideme").hide();

    });

});

OnChange is added to the dropDownRange, as in your example the function is not being called.
In your html markup the hideme is specified as a class and not an id so use the period(.) to find it instead of the hash(#).
 
Share this answer
 
Fiddle for your solution[^]

Please check the fiddle. I did this as far as my understanding. Hope I meant correct.
Please check.
Thanks
:)
 
Share this answer
 

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