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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:06:05+00:00 2026-05-17T22:06:05+00:00

I have been trying to do this all day. At the end i managed

  • 0

I have been trying to do this all day. At the end i managed to get it working. I know it is not the best way to do.

Can someone please show me a better way. I need 12 altogether. It does not need to be check box either. It can be just a text. I got the idea from com/2006/12/14/using-jquery-to-show-hide-form-elements-based-on-a-checkbox-selection/

I managed to upload it on http://utilitybase.com/paste/wmq

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script> 
<script type="text/javascript">
    $(document).ready(function(){

        //Hide div w/id extra
       $("#extra").css("display","none");

        // Add onclick handler to checkbox w/id checkme
       $("#checkme").click(function(){

        // If checked
        if ($("#checkme").is(":checked"))
        {
            //show the hidden div
            $("#extra").show("fast");
        }
        else
        {      
            //otherwise, hide it 
            $("#extra").hide("fast");
        }
      });

    });
</script>

<script type="text/javascript">
    $(document).ready(function(){

        //Hide div w/id extra
       $("#extra1").css("display","none");

        // Add onclick handler to checkbox w/id checkme
       $("#checkme1").click(function(){

        // If checked
        if ($("#checkme1").is(":checked"))
        {
            //show the hidden div
            $("#extra1").show("fast");
        }
        else
        {      
            //otherwise, hide it 
            $("#extra1").hide("fast");
        }
      });

    });
</script>

<script type="text/javascript">
    $(document).ready(function(){

        //Hide div w/id extra
       $("#extra2").css("display","none");

        // Add onclick handler to checkbox w/id checkme
       $("#checkme2").click(function(){

        // If checked
        if ($("#checkme2").is(":checked"))
        {
            //show the hidden div
            $("#extra2").show("fast");
        }
        else
        {      
            //otherwise, hide it 
            $("#extra2").hide("fast");
        }
      });

    });
</script>

<script type="text/javascript">
    $(document).ready(function(){

        //Hide div w/id extra
       $("#extra3").css("display","none");

        // Add onclick handler to checkbox w/id checkme
       $("#checkme3").click(function(){

        // If checked
        if ($("#checkme3").is(":checked"))
        {
            //show the hidden div
            $("#extra3").show("fast");
        }
        else
        {      
            //otherwise, hide it 
            $("#extra3").hide("fast");
        }
      });

    });
</script>

<script type="text/javascript">
    $(document).ready(function(){

        //Hide div w/id extra
       $("#extra4").css("display","none");

        // Add onclick handler to checkbox w/id checkme
       $("#checkme4").click(function(){

        // If checked
        if ($("#checkme4").is(":checked"))
        {
            //show the hidden div
            $("#extra4").show("fast");
        }
        else
        {      
            //otherwise, hide it 
            $("#extra4").hide("fast");
        }
      });

    });
</script>
</head>

<body>

<div style="width: 800px;">
        <form>

            <input type="text" name="" maxlength="30" />
            <label for="checkbox"> Check to enter another email address:</label>
            <input id="checkme" type="checkbox" />

            <div id="extra">
            <input type="text" name="input" maxlength="30" />
            <label for="checkbox"> Check to enter another email address:</label>
            <input id="checkme1" type="checkbox" />

            <div id="extra1">
            <input type="text" name="" maxlength="30" />
            <label for="checkbox"> Check to enter another email address:</label>
            <input id="checkme2" type="checkbox" />

            <div id="extra2">
            <input type="text" name="" maxlength="30" />
            <label for="checkbox"> Check to enter another email address:</label>
            <input id="checkme3" type="checkbox" />

            <div id="extra3">
            <input type="text" name="" maxlength="30" />
            <label for="checkbox"> Check to enter another email address:</label>
            <input id="checkme4" type="checkbox" /> 

            <div id="extra4">
            <input type="text" name="" maxlength="30" />
             </div>
           </div>
          </div>
         </div>
       </div>
  </form>
</div>
</body>
</html>

  • 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-17T22:06:06+00:00Added an answer on May 17, 2026 at 10:06 pm

    If I got you right, you might play around with

    <head>
      <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript"></script>
      <script type="text/javascript">
        $(document).ready(function(){
          var prototype = $('.prototype').clone();
    
          $('.prototype > input[type="checkbox"]').live('click', function() {
            if($(this).is(':checked')) {
              var clone = prototype.clone();
              clone.find('input[type="checkbox"]').attr('checked', false);
              $(this).parent('.prototype').append(clone);
            } else {
              $(this).parent('.prototype').find('.prototype:last').remove();
            }
          });
        });
      </script>
    </head>
    
    <body>
      <form>
        <div class="prototype">
          <input type="text" name="" maxlength="30" />
          <label for="checkbox"> Check to enter another email address:</label>
          <input id="checkme" type="checkbox" />
        </div>
      </form>
    </body>
    </html>
    

    EDIT: This add’s a new input/label/checkbox prototype inside the current one or removes it’s children on the other hand. You could add ids to the fields as well.

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

Sidebar

Related Questions

I have been trying to get around this error for a day now and
I have been working all day but unable to achieve this : It is
Have been struggling all day trying to make this simple example work using socket.io.
Ok, I have been working on solving this problem all day, and I am
Been trying to figure this one out all day. I have a large text
http://pastebin.com/AreCLL5W Could anyone help me with this, I've been trying all day to get
I've been stuck on this all day. I have a setup like the one
I've been trying to fix this problem almost all day (or it feels like
I've been trying to solve this problem all day, and I've read some conflicting
I have been trying to find out the problem to this for a day

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.