Sure. Good suggestion.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Matthias Wessendorf
Sent: Friday, July 21, 2006 12:28 AM
To: MyFaces Discussion
Subject: Re: need javascript syntax to loop through checkbox list from
dataTable
Hi Julian,
I think this is useful for others too.
can you (again) put it to our wiki ?
Thank you!
On 7/18/06, Julian Ray <[EMAIL PROTECTED]> wrote:
> We do exactly the same thing. Here is my JS.
>
> Note how the checkboxes are named. We have one funcrtion which toggles
> checks on and off and another which checks for one or more checked.
>
>
>
> /*
> * Browser-safe get object. Tries all three approaches to get an
> object
> * by its element Id.
> *
> * Param: objId - String - id of element to retrieve.
> * Param: formId - String - id of form (optional).
> * Returns: element or null if not found.
> */
> function getObj(objId, formId) {
> var fullId = objId;
> if (formId != null && formId.length > 0) {
> fullId = formId + ':' + objId;
> }
> //alert('getting object: ' + fullId);
> var elem = null;
> if (document.getElementById) {
> elem = document.getElementById(fullId);
> } else if (document.all) {
> elem = document.all[fullId];
> } else if (document.layers) {
> elem = document.layers[fullId];
> }
> return elem;
> }
> /*
> * Browser-safe. Check or uncheck an array of checkboxes. Boxes have
> ids
> * like check[0], check[1], ... , check[n] where 'check' is the base
> Id that
> * has been assigned to the group.
> *
> * Param: arrayId - String - id of element group to change
> * Param: state - boolean - true (check all elements) false
> (uncheck all elements)
> * Returns: nothing
> */
> function checkBoxArraySet(arrayId, state) {
> for (i = 0; ; i++) {
> id = arrayId + '[' + i + ']';
> elem = getObj(id);
> if (elem == null) {
> break;
> } else {
> elem.checked = state;
> }
> }
> }
> /*
> * Browser-safe. Checks to see if an array of check boxes has any
> which are
> * checked. Boxes have ids like check[0], check[1], ... , check[n]
> where 'check'
> * is the base Id that has been assigned to the group.
> *
> * Param: arrayId - String - id of element group to change
> * Returns: boolean (true one or more checked) false (else)
> */
> function checkBoxArrayHasChecked(arrayId) {
> for (i = 0; ; i++) {
> id = arrayId + '[' + i + ']';
> elem = getObj(id);
> if (elem == null) {
> break;
> } else if (elem.checked) {
> return true;
> }
> }
> return false;
> }
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, July 18, 2006 2:41 PM
> To: MyFaces Discussion
> Subject: need javascript syntax to loop through checkbox list from
> dataTable
>
>
>
>
>
>
> hello to everyone
>
> I'm using a tomahawk dataTable where one of the t:columns contains a
> t:selectBooleanCheckbox
>
> The tag has id and a forceId="true" attributes.
>
> In the rendered html, the id of the checkbox is foo[0], foo[1] etc
>
> I need to be able to loop through this list and look for a .checked
> property.
>
> I've tried all the loop mechanisms usually described for checkboxes
> but can't hit on the proper javascript syntax. googled till my eyes
> glazed over.
>
> can someone provide an example or a good reference to resolve this?
>
> Thanks in advance for your time and help.
> Tom
>
>
>
>
> This message is intended for the recipient only and is not meant to be
> forwarded or distributed in any other format. This communication is
> for informational purposes only. It is not intended as an offer or
> solicitation for the purchase or sale of any financial instrument, or
> security, or as an official confirmation of any transaction. Putnam
> does not accept purchase or redemptions of securities, instructions, or
authorizations that are sent
> via e-mail. All market prices, data and other information are not
> warranted as to completeness or accuracy and are subject to change
> without notice. Any comments or statements made herein do not
> necessarily reflect those of Putnam, LLC (DBA Putnam Investments) and
> its subsidiaries and affiliates. If you are not the intended
> recipient of this e-mail, please delete the e-mail.
>
>
--
Matthias Wessendorf
further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com