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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:54:54+00:00 2026-05-26T01:54:54+00:00

I have many checkboxes in a dynamically produced (ASP) photo gallery. Each checkbox has

  • 0

I have many checkboxes in a dynamically produced (ASP) photo gallery. Each checkbox has the name ‘photos’ and contains a photo ID in the value, like this:

<form name="selectForm" id="selectForm">
<input type="checkbox" onclick="selectPhoto(<%=rs1.Fields("photoID")%>)" id="checkbox_<%=rs1.Fields("photoID")%>" class="photos" name="photos" value="<%=rs1.Fields("photoID")%>">
</form>

Without submitting a form, when the user clicks the checkbox, I need to create a comma (,) separated list of all the checked values for the checkbox named ‘photos’. So this is what I tested but it alerts ‘undefined’! The ASP is correct, for those not familiar with it.

function selectPhoto(id) {
... other stuff that uses id ...
var allValues = document.selectForm.photos.value;
alert(allValues);
}

But as I said above, this returns ‘undefined’ and I can work out why. When a user selects a photo, I simply need to display a list of all the photo ID’s that have been clicked e.g. 1283,1284,1285,1286…

Any ideas what I am doing wrong here? Or is there another way to 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-05-26T01:54:55+00:00Added an answer on May 26, 2026 at 1:54 am

    I believe that the problem comes from the fact that “document.selectForm.photos” is not an input but an array. I have some code for you that worked:

    <script>
    function selectPhoto(id) {
        var allCheckbox = document.selectForm.photos;
        var allValues = []
        for (var i=0; i<allCheckbox.length; i++){
            if (allCheckbox[i].checked){
                allValues.push(allCheckbox[i].value)
            }
        }
        alert( allValues.join(',') )
    }
    </script>
    
    <form name="selectForm" id="selectForm">
        <input type="checkbox" onclick="selectPhoto(1)" id="checkbox_1" class="photos" name="photos" value="1">
        <input type="checkbox" onclick="selectPhoto(2)" id="checkbox_2" class="photos" name="photos" value="2">
        <input type="checkbox" onclick="selectPhoto(3)" id="checkbox_3" class="photos" name="photos" value="3">
        <input type="checkbox" onclick="selectPhoto(4)" id="checkbox_4" class="photos" name="photos" value="4">
        <input type="checkbox" onclick="selectPhoto(5)" id="checkbox_5" class="photos" name="photos" value="5">
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dynamically produced photo gallery using ASP. Each photo is contained by
I have a form that has many dynamically generated checkboxes. At runtime, how can
I have this not so many checkboxes: <input type=checkbox id=mango value=mango /> <label>MANGO</label><br> <input
I have a form that has many checkboxes (too many for it to make
I have a table style page with rows. Each row has a checkbox. I
I have a form on the page. It has too many things like checkboxes
I have a many-to-one relationship that users can edit via checkboxes. PK of Foo
I have many items inside a list control. I want each item to have
I have a small program with many widgets like checkboxes, textctrls, statictexts,... The values
I have a application that in one form( Form1 ) I have many checkBoxes

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.