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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:57:29+00:00 2026-05-16T20:57:29+00:00

So I am adding text and textbox to a page dynamically if a checkbox

  • 0

So I am adding text and textbox to a page dynamically if a checkbox is selected. However, the dynamic part is that the code behind is creating a CheckBoxList and appending text from a Code table to each checkbox. Therefore, I am looking for any checkbox with the ID that contains “chkCheckBox”. From there, I can check if the next to the checkbox is “Other” and if so insert the line of HTML in the last line below.

    $("input:checkbox[id*=chkSomeCheckBox]").click(function() {
        if ($(this).next().html() == "Other") {
            $("<span> : </span><input type='textbox'>").insertAfter($(this).next());
        }
    });

PROBLEM: The problem I am having is obviously if they uncheck the box, it appends ANOTHER textbox next to the first one, and this continues.

Help: I am having problems figuring out how to check if they are putting a check in the checkbox and only place the HTML if true. Secondly, if they uncheck the checkbox that meets the condition of ( == “Other) then remove the textbox I dynamically placed.

I figure its going to use the JQuery “remove()” event, but I am not sure how to tie in (this) with the :checked selector.

Any suggestions?

  • 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-16T20:57:31+00:00Added an answer on May 16, 2026 at 8:57 pm
    $("input:checkbox[id*=chkSomeCheckBox]").click(function() {
            if ($(this).next().html() == "Other" && $(this).is(':checked')) {
                $("<span> : </span><input type='textbox'>").insertAfter($(this).next());
            }
            else if($(this).next().html() == "Other"){
               $(this).next().empty();
            }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am adding HTML input controls on the page dynamically via a add text
I suspect that adding a certain letter/character to the beginning of my text will
I am adding element dynamically to DOM. $('<div class=entry></div>').text(data.status).appendTo(app.twitter_feed); I want to get element
on my MVC3 razor page,I am trying to dynamically add a textbox with click
I have following textbox in my first HTML page: <input tabindex=4 type=text class=search_textbox roundedCorners
My ASP.NET page has an <asp:TextBox /> whose text input is encoded via HttpUtility.HtmlEncode();
I am adding controls dynamically to my page on the basis on a condition.There's
I am creating text boxes dynamically. I want to take those text box values
I am adding text incrementally to a wrapping CATextLayer in a UIScrollView . Each
I have a django 1.3 project and I'm in the process of adding text

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.