Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I face a problem. I have two button "Show Selected" and "Show All". when my page is loaded then "Show Selected" is visible and "Show All" is hide. now i want when i click on "Show Selected" then "Show all" is visible. Now Problem is Every time on click of "Show Selected" page is loaded. How i fix that.

Thanks

Here Is my Code
 @using (Html.BeginForm())
{
              @Html.ValidationSummary(true, "", new { @class = "alert-danger" })
            <div class="serchfield-container">           
                <div class="main-button2" >
                  
                    <div class="imageHolder" id="undo">
                        <a href=" #" id="btnundo" name="btnundo" class="hint--top" data-hint=" Show All">
                            <img src="/Content/images/undo.png" alt="" title="">
                        </a>
                    </div>                  
                    <div id="divbtn">                      
                        <div class="imageHolder">
                            <a href="#" id="btnselected" name="btnselected" class="hint--top" data-hint=" Show Selected">
                                <img src="/Content/images/selected.png" alt="" title="">
                            </a>
                        </div>    
 </div>    
} 

here is my Jquery Code
JavaScript
<script>
         $(document).ready(function () {
             $('#undo').css({ "display": "none" })
 $("#btnselected").click(function () {
           var txt = "Selected";
           GetCheckedRecord();
           if (checkval.length > 1) {
               $.post('/NewResult/ShowSelectedID/', $.param({ Ids: checkval, btn: txt }, true), function (data) {
                   window.location.href = '@Url.Action("Index", "NewResult")';
               });
               Show_Div(txt);
           }
           else
               alert('Please select Records First.');
       });

       });

 function Show_Div(btn) {
           if (btn === "Selected") {
               $('#undo').css({ "display":"block" })
           }
           else {
               $('#undo').css({ "display": "none" })
           }
       }
   </script>
Posted
Updated 29-Jun-16 1:19am
v2
Comments
deepankarbhatnagar 11-Jan-16 6:25am    
show your code please

1 solution

JavaScript
$(document).ready(function () {        
          $("#divdraw").hide();          
 $("#btnselected").click(function () {
           var txt = "Selected";
           GetCheckedRecord();
           if (checkval.length > 1) {
               $.post('/NewResult/ShowSelectedID/', $.param({ Ids: checkval, btn: txt }, true), function (data) {
                   window.location.href = '@Url.Action("Index", "NewResult")';
               });
                $("#divdraw").show();
           }
           else
               alert('Please select Records First.');
       });
 
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