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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:17:22+00:00 2026-06-18T21:17:22+00:00

I used the jquery below to auto populate a textbox based on values of

  • 0

I used the jquery below to auto populate a textbox based on values of checked or unchecked check boxes

function updateTextArea() {
        var allVals = [];

        $('#all :checked').each(function () {
                allVals.push($(this).val());
        });

        document.getElementById('txtbox').value = allVals;
    }
    $(function () {
        $('#all input').click(updateTextArea);
        updateTextArea();
    });

and my html code is

<div id="all">
<input id="txtbox" type="text" Height="100px"  Width="770px"  />   
  <input id="Checkbox2" type="checkbox" value="abc1@abc.com" />
  <input id="Checkbox3" type="checkbox" value="abc2@abc.com" />
  <input id="Checkbox4" type="checkbox" value="abc3@abc.com" />
  <input id="Checkbox5" type="checkbox" value="abc4@abc.com" />

</div>

The above jquery works wells for every check and uncheck events of checkboxes and populating its values to textbox separated by comma, My issue is if someone manually enters some email separated by comma in the above textbox I want that value to be retained and not to be refreshed for the check and uncheck events of my check box. How can I achieve this?

  • 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-18T21:17:23+00:00Added an answer on June 18, 2026 at 9:17 pm

    The general technique that I would use to solve this is:

    On every check or uncheck:
    1. Split the list by comma into an array.
    2. Gather all preset email values that are checked (you’re doing this already).
    3. Find every split value that isn’t in the preset array, and set it aside.
    4. Insert all your checked preset values, and then add in all the oddballs, or vice versa.

    This doesn’t preserve order, but it does retain any manually entered values. Retaining order could be done but would be a little more tricky.

    You might also consider just having a separate “additional email” text box which would reduce the complexity of this and potentially make it more intuitive for the user.

    Code:

    function updateTextArea() {
        var allVals = [];
        var checkedVals = [];
    
        $('#all input[type=checkbox]').each(function () {
            allVals.push($(this).val());
        });
    
        $('#all :checked').each(function () {
            checkedVals.push($(this).val());
        });
    
        var potentialOtherEmails = $("#txtbox").val().split(",");
        var confirmedOtherEmails = [];
        $(potentialOtherEmails).each(function(index,value) {
            if ($.inArray(value, allVals) == -1) {
                confirmedOtherEmails.push(value);
            }
        });
    
        $("#txtbox").val($.merge(checkedVals,confirmedOtherEmails));    
    }
    
    $(function () {
        $('#all input').click(updateTextArea);
        updateTextArea();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used Jquery to insert a variable to div. Please check my code. var
I wrote a jQuery script (below) and I used the (document).ready(function($)) function does it
The markup below is used for my jQuery carousel widget. The first div serves
I am having a very specific problem in JQuery The code below is used
i've used jquery load method for a website pagination here is my code function
Please see the jQuery code below, it used to paginate some search results paginate:
I have used jQuery library to find out height of a div . Below
I already used jquery combobox autocomplete like on the demo below. jquery combobox autocomplete
For example, I'm using the script below to check for empty fields : $('a.submit').click(function()
I used the below tab content script. which used jquery code and jquery ui

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.