Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8457149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:44:09+00:00 2026-06-10T12:44:09+00:00

I am trying to hide a button in a table column based on another

  • 0

I am trying to hide a button in a table column based on another column value, there’s a table column field call “Archive” and if that value is true, I want to hide a button from another column. The code below I have however only hides the button in the first row and ignore subsequent rows. Please kindly assist. Thanks.

<table class="table table-striped table-bordered">
    <tr>
        <td width="8%" class="table_pink" style="background-color:#ED4085">Name</td>
        <td width="8%" class="table_pink" style="background-color:#ED4085">Email</td>
        <td width="8%" class="table_pink" style="background-color:#ED4085">Country</td>
        <td width="8%" class="table_pink" style="background-color:#ED4085">Time</td>
        <td width="5%" class="table_pink" style="background-color:#ED4085">WrongAtQuestion</td>
        <td width="5%" class="table_pink" style="background-color:#ED4085">Winner?</td>
        <td width="5%" class="table_pink" style="background-color:#ED4085">CreatedDateTime</td>
        <td width="5%" class="table_pink" style="background-color:#ED4085">Hidden</td>
        <td width="20%" class="table_pink" style="background-color:#ED4085">Action</td>
    </tr>

    @foreach (var item in Model)
    {
        if (item.Archive)
        {
            <script type="text/javascript">
                $('#hideButton').hide();
            </script>
        }

           <tr>
               <td>@item.Name</td>
               <td>@item.Email</td>
               <td>@item.Country</td>
               <td>@item.Time</td>
               <td>@item.WrongAtQuestion</td>
               <td>@item.IsWinner</td>
               <td>@item.CreatedDateTime</td>
               <td>@item.Archive</td>
               <td><a class="btn btn-primary" href="#" id="hideButton" onclick="deleteEntry('@item.Id', '@item.Name'); return false;"><i class="icon-white icon-trash"></i> Hide from Leaderboard</a></td>
           </tr>         
    }
</table>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:44:10+00:00Added an answer on June 10, 2026 at 12:44 pm

    Well the first problem is that you are creating invalid html. The id attribute is supposed be unique, but in every row you’re outputting an anchor with id="hideButton".

    When you then use $('#hideButton') it will find (in most browsers) the first element with that id, not all of them. But even if duplicate ids were allowed, there’s nothing to tie the script with $('#hideButton').hide() to any particular row – just because the script block happens to precede the row doesn’t make a connection between them.

    I’d suggest instead that you get rid of that script block entirely, and then use a server-side if inside the td element with the link to only include the link if item.Archive is false. Then you wouldn’t need any JS/jQuery/CSS. I’m not familiar with the server-side language you’re using, but in pseudo code it might look something like this:

    <td>
        @if(!item.Archive){
        <a class="btn btn-primary" href="#" onclick="deleteEntry('@item.Id', '@item.Name'); return false;"><i class="icon-white icon-trash"></i> Hide from Leaderboard</a>
        }
    </td>
    

    Another alternative would be to use server-side code to add class="archive" to the relevant anchor elements, and then use this jQuery:

    $(document).ready(function() {
         $("a.archive").hide();
    });
    

    (Or if you need to do other operations depending on the archive status you might like to put the class on the tr element and use $("tr.archive a.btn").hide();.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to hide the div class hideme based on value of full_day
i am trying to show/hide a flash object based on click of button, but
im trying to hide inserted rows into a table that have the class newrow.
I'm currently trying to hide a dynamically created table row after a button has
I am trying to hide the button based on the user's role using the
I'm trying to toggle (hide/show) a table when clicking a button which is located
I'm trying to hide a button if it contains the value 'foo'. The code
Okay, so I'm trying to write a simple show/hide content button, but I want
I'm trying to create a Hide/Show button with jQuery. When .cminus is clicked, it
I am trying to hide/show/toggle a div when a button is clicked. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.