# Multiple selection

**URL:** <https://www.ruby-forum.com/t/multiple-selection/50565>\
**Category:** Rails\
**Created:** [December 18, 2005, 5:41am UTC](https://www.ruby-forum.com/t/multiple-selection/50565 "2005-12-18T05:41:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kitesurfer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@kitesurfer](https://www.ruby-forum.com/u/kitesurfer)\
**Post date:** [December 18, 2005, 5:41am UTC](https://www.ruby-forum.com/t/multiple-selection/50565/1 "2005-12-18T05:41:15Z")

</div>

Hi,

I have a table with a paginator and each row displays its own  
checkbox.  
I want to be able to offer actions like  
select\_all/deselect\_all/select\_partial.  
The problem how does on record user actions so that the form is  
correctly posted once the user hits submit ?

Can anyone point me out to an elegant solution to this common problem  
?  
Code or article would be great !!

Many Thanks…

---

<div class="post-metadata">

**Author:** ![kitesurfer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@kitesurfer](https://www.ruby-forum.com/u/kitesurfer)\
**Post date:** [March 17, 2007, 9:36am UTC](https://www.ruby-forum.com/t/multiple-selection/50565/2 "2007-03-17T09:36:12Z")

</div>

Hi,

```
  Every Html controls should have id field. So, first make urself to 

```

use id for any field, even it is a simple text box, Okay. This will make  
u code well & efficient. If, u don’t understand, no pbm. Just keep it.  
Later, u will understood. Then,

For ur problem,  
—\> Assign a id for ur form.  
  
—\> Have a link like this,  
Check&nbsp;All  
UnCheck All  
—\> For this, u need foll. javascript code,  
  
function checkAll(t){  
var el = document.getElementById(t);  
for (var i = 0; i \< el.elements.length; i++) {  
el.elements[i].checked = true;  
}  
}

```
       function unCheckAll(t){
          var el = document.getElementById(t);
    for (var i = 0; i < el.elements.length; i++) {
       el.elements[i].checked = false;
    }
       }
    </script>

```

—\> Come on. What happens? Bye. Thank U!!!.

De Railed wrote:

> Hi,
> 
> I have a table with a paginator and each row displays its own  
> checkbox.  
> I want to be able to offer actions like  
> select\_all/deselect\_all/select\_partial.  
> The problem how does on record user actions so that the form is  
> correctly posted once the user hits submit ?
> 
> Can anyone point me out to an elegant solution to this common problem  
> ?  
> Code or article would be great !!
> 
> Many Thanks…
