Access repeater checkboxes via javascript getElementByID

Posted on 2004-04-29
Last Modified: 2012-06-27
My repeater is creating checkboxes, but it gives them a real long id, like

Is there a way to access these via javascript without hard coding that string?

The reason I ask is because I have a user control which is included in many pages and therefore the ID's of the checkboxes change depending on where it is included.

thanks in advance.
Question by:Rodney Helsens
  • 3
  • 2

Accepted Solution

chisholmd earned 125 total points
ID: 10950431
Sure, If they are the only checkbox elements on the page you could do something like:

           //do something

What do you need to do with the checkboxes with your client side code?


Author Comment

by:Rodney Helsens
ID: 10950846
thanks for the response.

The challenge is, I would like to emulate the 'select all/deselect' all type functionality BUT on a per row basis.

So the repeater would have 5 columns with a checkbox in each, and also have a button or control that when clicked, would select/deselect all checkboxes on that row using javascript.

I have the code to do it, but as I said in my original comment, assigns an ID to the checkboxes and I am not sure how to deal with that.



Author Comment

by:Rodney Helsens
ID: 10950862
I used your suggestion with some modification and got it working, thanks for jarring my brain!

function toggleCheckBoxes(isChecked, val)
var re = '_sharedAccessControl_Repeater1__ctl' + val + '_chk';
for(i = 0; i < document.all.length; i++)
   elm = document.all[i];
   if (elm.type=='checkbox')
      if ( >= 0)
         elm.checked = isChecked

Expert Comment

ID: 10950997
Great!, If you only wanted to do one row then I assume the select/deselect all is contained in that row, maybe at the end. If so you could pass "this" from the button/link. Then from that reference you could walk up the DOM to the table row and loop through only that row looking for checkboxes.

function selectDeselectRow(btn_el){
      var td = btn_el.parent
      var tr = td.parent
             //if a checkbox is checked uncheck else check

Or something like that but cross browser compatible :)

Author Comment

by:Rodney Helsens
ID: 10951120
Yeah, thanks I'll try that

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
An ASP query I cannot work out... 2 46
Issue with Loop 4 50
Update table value with join syntax 2 60
JQuery to parse xml string and get element by id 4 23
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now