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

  • Home
  • SEARCH
  • 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 6353051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:20:32+00:00 2026-05-24T22:20:32+00:00

I have a Jquery toggle which contains an entry form to a MySQL table.

  • 0

I have a Jquery toggle which contains an entry form to a MySQL table.

Directly below this toggle I am displaying the data in a list.

What I would like to do is have it so that the toggle is in it’s opened state (removal of “display:none”) if the table has no records. And of course be closed if the table does contain records.

To make matters more complicated my table is hard filtered to the logged in user, so I would only the want the toggle to defaut to the open state if there are no records on the table matching the logged in user.

I hope that makes sense!

My PHP knowledge is poor at best so please go easy on me.

Here’s my toggle code:-

(function($) { $.fn.simpleToggle = function(opts) {
    var options = $.extend({}, $.fn.simpleToggle.defaults, opts);

    return this.each(function() {
        $title = $(this).children('.togTitle');
        $title.each(function() {
            $(this).click( function() {
                $item = $(this);
                $item.next('.togDesc').slideToggle('fast', function() {
                    $icon = $item.children('.iconSymbol');
                    if ($(this).css('display') == 'block') {
                        $icon.removeClass('plus').addClass('minus');
                    } else {
                        $icon.removeClass('minus').addClass('plus');
                    }
                });
            });
        });
    });

}
$.fn.simpleToggle.defaults = {}
})(jQuery);
  • 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-05-24T22:20:32+00:00Added an answer on May 24, 2026 at 10:20 pm

    it’s quite hard to imagine the underlying dom.

    However, something like this could do the trick:

    (function($) { $.fn.simpleToggle = function(opts) {
        var options = $.extend({}, $.fn.simpleToggle.defaults, opts);
    
        return this.each(function() {
            $title = $(this).children('.togTitle');
            $title.each(function() {
                $('.togDesc', this).each( function () {
                    if ( $(this).children('.iconSymbol').length == 0 ) {    
                        $(this).show();                                 
                    }
                });
                $(this).click( function() {
                    $item = $(this);
                    $item.next('.togDesc').slideToggle('fast', function() {
                        $icon = $item.children('.iconSymbol');
                        if ($(this).css('display') == 'block') {
                            $icon.removeClass('plus').addClass('minus');
                        } else {
                            $icon.removeClass('minus').addClass('plus');
                        }
                    });
                });
            });
        });
    
    }
    $.fn.simpleToggle.defaults = {}
    })(jQuery);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
I have this jQuery code, which uses the toggle() function on a checkbox input
I have this jQuery: $(document).ready(function() { $(#panel).hide(); $('.login').toggle( function() { $('#panel').animate({ height: 150, padding:20px
Really quick jQuery question... I have this function: $(document).ready(function() { $('a#show1').click(function() { $('.item1').toggle(1000); return
I have the following jQuery code which all works fine: $(#sidebar .m3, #sidebar .m5).toggle(function()
I have a form which is validated through jquery, but I need the blur
I'm using Javascript/Jquery to have a button toggle which div is displayed in the
I have a DIV element which has a jQuery.toggle Event. If I add a
i Would like to do do one webpart which contains Jquery effects like toggle
I have a jquery toggle that animates and displays a DIV. I have a

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.