Click here to Skip to main content
14,327,583 members
Rate this:
Please Sign up or sign in to vote.
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
<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

Rate this:
Please Sign up or sign in to vote.

Solution 1

$(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.');
       });
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100