Link to home
Start Free TrialLog in
Avatar of lovettjay
lovettjay

asked on

Show and Hide a div based from drop down list

Show and Hide a div based from drop down list.  I have three status, Approved, Pending or Rejected. The problem I'm having is when the default value is "Approved" or "Pending" the text box that I'm trying to hide is still visible.  Once inside the drop down list I can toggle the selection and it will then show or hide the text box correctly.  I would like to have this functionality work on the page load.

I have tried both CSS and Jquery and I'm haivng the same issue with both.  

Text Box
 <div id="hideRejectReason">
                        @Html.EditorFor(model => model.rejection_reason)
                </div>

Open in new window



 function show() {

        var select_status = $('#select').val();
       
        if (select_status == 'Rejected') {
            $('#hideRejectReason').show();          
        }

        else {
            $('#hideRejectReason').hide();          
        }

    }

Open in new window



  function show() {

        var select_status = $('#select').val();

        if (select_status == 'Rejected') {
            $('#hideRejectReason').css('display', 'block');         
        }

        else {
            $('#hideRejectReason').css('display', 'none');
        }

    }

Open in new window

SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lovettjay
lovettjay

ASKER

The alert box for $('#select').length) all shows a 1 for all selections.  However the $('#select').val() returns the correct value.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help.  I appreciate your time.