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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:07:02+00:00 2026-05-23T05:07:02+00:00

I have a form. Let’s called it myform. Inside there are checkboxes, such as

  • 0

I have a form. Let’s called it myform.

Inside there are checkboxes, such as these two:

<input type='checkbox' name='power_convention[]' value='SOME VALUE #1' />
<input type='checkbox' name='power_evidence[]' value='SOME VALUE #2' />

At the end of the form, there’s a textarea.

<textarea id="elm1" name="comments" rows="15" cols="80" style="width: 80%">

If power_convention is checked, I want it to immediately append the value of that checkbox into the comments checkbox with the following structure:

<h3>SOME VALUE #1</h3><br />

Similarly, if power_evidence is clicked, I want it to do the same thing, but obviously after whatever came before it.

How would I go about doing this?

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-05-23T05:07:03+00:00Added an answer on May 23, 2026 at 5:07 am

    A jQuery solution:

    $('input[type="checkbox"]').change(function() {
        var val = "<h3>" + this.value + "</h3><br />";
        if(this.checked) {
            $('#elm1').val(function(i, v) {
                return v + val;
            });
        }
        else {
            $('#elm1').val(function(i, v) {
                return v.replace(new RegExp(val), '');
            });
        }
    });
    

    DEMO

    This only works if val does not contain any special regular expressions characters. In this case you would have to escape them.

    Update: Actually, you don’t need a regular expression here, v.replace(val, '') will be just fine (thanks @Pinkie);

    An alternative to regular expressions would be to recreate the content of the textarea:

    var $inputs = $('input[type="checkbox"]');
    $inputs.change(function() {
        var val = "<h3>" + this.value + "</h3><br />";
        if(this.checked) {
            $('#elm1').val(function(i, v) {
                return v + val;
            });
        }
        else {
            $('#elm1').val('');
            $inputs.not(this).change();
        }
    });
    

    DEMO 2

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

Sidebar

Related Questions

Let's assume I have a form with these fields (HTML) <input type=text name=user[name] value=name/>
Let's say we have this form: <form> <input type=text name=some_name value=val id=some_name> <input type=image
Let say that I have the form below: <form action=sendMessage.php method=post> <label>Subject</label><input type=text></input> <label>Message</label><input
Let's say I have an html form. Each input/select/textarea will have a corresponding <label>
Let's say you have a custom form MyForm : Form and want to run
Let's say I have some form where user input some WCF/RIA Services URL and
I have a c# form (let's call it MainForm) with a number of custom
Let's say you have a form with a component that displays data from a
Let's say I have a form that collects a first name and a last
Let's say I have a form where users can search for people whose name

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.