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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:16:09+00:00 2026-06-13T05:16:09+00:00

I am trying to add a checkbox list to a form. When I use

  • 0

I am trying to add a checkbox list to a form. When I use the following code, I get all the items in the array but no checkboxes, so I cannot select anything. I’m sure there is a very simple solution to this, but I can’t see what I’m doing wrong (I’m new at this). Many thanks in advance for your help. Here is the code:

var check_value = new Array()
check_value[0] = "I work at home"
check_value[1] = "Train/Subway"
check_value[2] = "Walk"
check_value[3] = "Bicycle"

for(count in check_value)
    {
    var ptworkinfo=document.createElement("input");
    ptworkinfo.type="checkbox";
    ptworkinfo=(check_value[count] + "</br>");
    ptworkinfo.id="ptworkinfo";
    document.write(ptworkinfo);
    count+=count;
    }
  • 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-13T05:16:11+00:00Added an answer on June 13, 2026 at 5:16 am

    There are a couple of problems here:

    1) Never use document.write – The standard, pure javascript implementation you need to be using is to appendChild to a parent element. For example:

    var parentElement = document.getElementById('myParentElement');
    
    if(parentElement != null)
       parentElement.appendChild(myChildElement);
    

    2) Using this knowledge, you can easily add elements with a simple rework of your statements:

    var parentElement = document.getElementById('myParentElement');
    
    for(var count in check_value)
    {
        var newCheckBox = document.createElement('input');
        newCheckBox.type = 'checkbox';
        newCheckBox.id = 'ptworkinfo' + count; // need unique Ids!
        newCheckBox.value = check_value[count] + '<br/>';
    
        parentElement.appendChild(newCheckBox);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use checkboxes to add users to a specific group but I'm
Trying to add a class object into a List using reflection, but when invoking
I am trying to add a checkbox to a List component in my application
I am trying to dynamically add some content to a list of checkboxes in
I am trying to make a list with items. These items contain a checkbox
I'm trying to build a form that will list all users and allow you
I was trying to add thumbnail to list view but the problem is that
I am trying to add a checkbox in a customized listview but don't know
I am trying to add a custom data-required attribute to an asp Checkbox control,
I am trying add picture boxes dynamically. My code is as PictureBox picture =

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.