Forum: Ruby on Rails Multiple selection....

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
De R. (Guest)
on 2005-12-18 06:41
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...
Saravanankumar S. (Guest)
on 2007-03-17 10:36
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.
         <form id='me' name='MyForm' action='something'>
 --->   Have a link like this,
         <a href='javascript:checkAll("me")'>Check&nbsp;All</a>
         <a href='javascript:unCheckAll("me")'>UnCheck All</a>
 --->   For this, u need foll. javascript code,
        <script language = 'javascript'>
           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...
This topic is locked and can not be replied to.