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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:51:17+00:00 2026-06-03T16:51:17+00:00

How can I add the check-box variable value to my text area based on

  • 0

How can I add the check-box “variable value” to my text area based on the users selection of check boxes above. I need it to add or remove, The drop-down works fine just need help with the check-box’s cant seem to get them to work.

Here is the code that II have so far:

<html>
<head>

</head>

<body>


  Image 1 <input type="checkbox" name="ImageVar1" id="ImageVar1" /><br />
  Image 2 <input type="checkbox" name="ImageVar2" id="ImageVar2" /><br />
  Image 3 <input type="checkbox" name="ImageVar3" id="ImageVar3" /><br />
  Image 4 <input type="checkbox" name="ImageVar4" id="ImageVar4" />

<p>&nbsp;</p>

  <select id="dropdown">
    <option value="">None</option>
    <option value="textVar1">text 1</option>
    <option value="textVar2">text 2</option>
    <option value="textVar3">text 3</option>
    <option value="textVar4">text 4</option>
  </select>

<p>&nbsp;</p>

  <textarea id="mytext"></textarea>

<script type="text/javascript">

var textVar1 = 'this is going to be a long sting of text for text 1 value ';
var textVar2 = 'this is going to be a long sting of text for text 2 value ';
var textVar3 = 'this is going to be a long sting of text for text 3 value ';
var textVar4 = 'this is going to be a long sting of text for text 4 value ';

var ImageVar1 = 'Image 1 value ';
var ImageVar2 = 'Image 2 value ';
var ImageVar3 = 'Image 3 value ';
var ImageVar4 = 'Image 4 value ';

var mytextbox = document.getElementById('mytext');
var mydropdown = document.getElementById('dropdown');

mydropdown.onchange = function(){
mytextbox.value = mytextbox.value  + window[this.value];

}
</script>

</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-06-03T16:51:19+00:00Added an answer on June 3, 2026 at 4:51 pm

    Here’s a no-framework (no jQuery/prototype) way way to do it.

    Example: http://jsfiddle.net/S5vcW/6/

    Though some browsers support document.querySelectorAll("input[type='checkbox']") which would make the script much simpler and more efficient.

    var inputs = document.getElementsByTagName("input");
    for(var i = 0; i < inputs.length; i++) {
        if(inputs[i].type === "checkbox" && inputs[i].name.indexOf('ImageVar') > -1) {
            inputs[i].onchange = function(){
                if(this.checked){
                    mytextbox.value = mytextbox.value  + ImageVars[this.name];
                }else{
                    mytextbox.value = mytextbox.value.replace(ImageVars[this.name], ""); 
                }
            }
        }  
    }
    

    And Here’s a jQuery version that accomplishes the same thing.

    Example: http://jsfiddle.net/S5vcW/5/

    $("input[type='checkbox'][name*='ImageVar']").change(function(){
        var $chk = $(this); 
        if($chk.prop('checked')){
            $mytextbox.val($mytextbox.val() + ImageVars[$chk.attr('name')]);
        }else{
            $mytextbox.val($mytextbox.val().replace(ImageVars[$chk.attr('name')], "")); 
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i add and remove rows in datagrid using check box` [Bindable]public var
How can you add 25 when you check that box and subtract 25 when
How can I add something in JavaScript that will check the website URL of
How can I add something in JavaScript that will check the web site URL
I can add and remove the last line in my dynamic form and calculate
Users on my site can add nodes of a custom type (let's call it
Im am trying to add a check box that will enable/disable the edit button.
I would like to add a simple check box to my form: $element =
I need a function that can add checkbox values on click event. My html
I want to add new field in My Account page, say check box for

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.