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 7996883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:49:17+00:00 2026-06-04T14:49:17+00:00

so lately i have been working on a little bit of js. so, basically,

  • 0

so lately i have been working on a little bit of js.

so, basically, my problem is that i need to hide whatever is passed in the parameters or show it if it already hidden.

Here is my code:

<script type='text/javascript'>
<!--
function toggleReport(table){
//the table argument is the table's id
alert(table);                    //to check that the name of the table is right
if($('#table').is(':visible')){ //check if visible
    $('#table').hide();     //if so, hide it
    alert('hide');          //send a message that it is now being hidden
}else{                          //if already hidden
alert('show');                  //send a message that it is now being shown
$('#table').show();             //show the table
}

}
//-->
</script>

however, it doesn’t work…. it is sending the alerts, and everything is correct, however, it does not hide or show the table….

but, if i try doing this:

<script type='text/javascript'>
<!--
function toggleReport(){
//removed the argument
alert('table_1');
if($('#table_1').is(':visible')){
    $('#table_1').hide();
    alert('hide');
}else{
alert('show');
$('#table_1').show();
}

}
//-->
</script>

It works! why is it like that? because im going to have many tables on the website and other things that need to be hidden and shown and i dont want to make a new function for each.. :/

Please help me!

THANKS!!

  • 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-04T14:49:19+00:00Added an answer on June 4, 2026 at 2:49 pm

    Very Simple use toggle() intead of show()/hide(), toggle() makes element visible if it is hide and hide it if it is visible.

    <script type='text/javascript'>;
    function toggleReport(element_ID){
    $("#"+element_ID).toggle();
    }
    </script>
    

    If you want to hard code the Element ID than use following script

    <script type='text/javascript'>
    function toggleReport(){
    $("#table_1").toggle();
    }
    </script>
    

    Cheers, and dont forgot to vote up my answer
    🙂

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

Sidebar

Related Questions

I have been working with SharpSVN quite a bit lately and I'm currently trying
I have been working with functional programming a good bit lately, and have found
I've been working with xml lately. And have noticed a bit of a phenomenon
I have been working lately on a number of iterative algorithms in MATLAB, and
I have been working with Exceptions lately. I think it makes sense to log
Situation I have been working on a project lately where the UI development seems
I am a photographer and I have been working on redesigning my website lately.
I've been having some strange errors lately. I have a working install of Git,
I have been working on large datasets lately (more than 400 thousands lines). So
I have been working in WPF web browsers lately but I can't seem to

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.