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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:00:40+00:00 2026-06-01T06:00:40+00:00

Fact: I’m not that good with jQuery. Problem: I have a form containing dynamically

  • 0

Fact: I’m not that good with jQuery.

Problem:

I have a form containing dynamically rendered radio buttons. When clicking on a radio button, I want a div to appear to give a text explanation. Within the “hidden” div I want a button or link to “close” the div. I have a set of 27 radio buttons, clicking on each WORKS perfectly fine it shows the proper div and I can click another radio button and it toggles to the next hidden div, except I can’t hide them after! But, I can hide the first radio button’s div, but I can’t hide any of the other 26, the button doesn’t do anything in those divs.

Here is the code for my radio buttons:

 $categoryQuery = "SELECT * FROM blah, blah";
 $categoryResult = mysqli_query($link, $categoryQuery );

                    while($row = mysqli_fetch_array($categoryResult)){

       $cat_id = $row['att_cat_id'];
       $category = $row['att_cat_name'];

 echo "<input type='radio' name='AttorneyCategory[]' value='$cat_id'> $category<br />";

Code for my hidden divs (created from my db):

 $categoryhelpQuery = "SELECT * FROM blah blah";
 $categoryhelpResult = mysqli_query($link, $categoryhelpQuery );

                    while($row = mysqli_fetch_array($categoryhelpResult)){

       $cat_id = $row['att_cat_id'];
       $category = $row['att_cat_name'];
       $category_description = $row['att_cat_description'];

 echo "<div id='blk-$cat_id' class='toHide'>";
 echo "<strong><em><center>Attorney Search Help Center</center></em></strong><button           id='hidr'>Hide</button><br />";
 echo "<strong>$category:</strong>&nbsp;&nbsp;$category_description";
 echo "</div>";

And here is my jQuery code:

 <script type="text/javascript"   src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

  <script type="text/javascript">
 $(function() {
     $("[name='AttorneyCategory[]']").click(function(){
        $('.toHide').hide();
        $("#blk-"+$(this).val()).show();
     });


 });

  $("#hidr").click(function () {
  $('.toHide').hide(1000);
 });


 </script>

Any help would be great.

  • 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-01T06:00:41+00:00Added an answer on June 1, 2026 at 6:00 am

    First thing: It looks like your

    $("#hidr").click(function () {
    $('.toHide').hide(1000);
    });
    

    is outside of your

    $(function(){
       // this part
    });
    

    As I’m sure you know, jQuery runs everything inside that function AFTER the page is ready to be accessed. Right now I think jQuery is looking for “#hidr”s and not finding any because this code will run as soon as it possibly can. Likely before the browser has made any “#hidr”s

    But wait! There’s more. Look closely at

     <button id='hidr'>Hide</button>
    

    You’re using an id! 🙂 There’s only supposed to be one thing on your page with any given id. Try using class instead. That way you can attach the .click event to every $(“.hidr”)

    Then, it’s only a matter of referencing the parent to make it all disappear. Like this:

     $(".hidr").click(function () {
       $(this).parent().hide(1000);
     });
    

    Good luck with your lawyer page!

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

Sidebar

Related Questions

Despite the fact that this is not good coding practice, I want a macro
In fact the UserControl lacks the property 'SizeToContent' that we have in Window. So
The fact that it is a LINQ result might perhaps not be relevant for
I have a fact table that has 17 keys. Normally I have been designating
Please excuse the fact that it's not a programming question, but it's still related
The fact that I don't know how to do this is a good example
Other than the obvious fact that the first form could use a variable and
In fact I have this working, just not correctly. I have a callback (posted
In fact it is not neccessary for me to have this tab active (I
I have a fact table that needs a join to a dimension table however

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.