I'm now wondering if the onchange event will allow me to set the value of
the hidden field BEFORE the form.observer fires the ajax call.... I'll test
that tomorrow... My thinking is that I'll set the value of a hidden field
to on/off and the name of the field to the record #.

On Wed, Apr 25, 2012 at 4:05 PM, Brian Marquis <br...@quotepro.com> wrote:

> Yes, that's the nature of checkboxes and radio buttons.  If you need the
> value submitted in all circumstances, then you're back to the hidden field
> implementation. Problem with that approach is that it won't work if the
> user has javascript disabled.****
>
> ** **
>
> A few options for event listeners (untested):****
>
> ** **
>
> $('tableid').observe('click',function(event) {****
>
>   var element = Event.element(event);****
>
>   if ( element.name == " ApprovedSubscribers" ) {****
>
>        new Ajax.Request( url, $H({ RecordId: element.value, Checked:
> element.checked }));****
>
> }****
>
> });****
>
> ** **
>
> Or****
>
> ** **
>
> $$("input[type='checkbox']").invoke("observe","click",function(event) {***
> *
>
>   var element = Event.element(event);****
>
>   if ( element.name == " ApprovedSubscribers" ) {****
>
>        new Ajax.Request( url, $H({ RecordId: element.value, Checked:
> element.checked }));****
>
> }****
>
> });****
>
> Brian Marquis | Quotepro® | Senior Developer | b...@quotepro.com | Phone: 
> 312.654.8045
> x122 / Fax: 312.654.1285****
>
> [image: image001]****
>
> *The information in this e-mail is confidential and may be legally
> privileged.  It is intended solely for the addressee.   Access to this
> e-mail by anyone else is unauthorized.*****
>
> ** **
>
> *From:* prototype-scriptaculous@googlegroups.com [mailto:
> prototype-scriptaculous@googlegroups.com] *On Behalf Of *Phil Petree
> *Sent:* Wednesday, April 25, 2012 2:01 PM
> *To:* prototype-scriptaculous@googlegroups.com
> *Subject:* Re: [Proto-Scripty] Tactical Advice: Many rows, one checkbox
> per row****
>
> ** **
>
> Funny, I had just figured out what you had suggested for getting rid of
> the hidden field and making the record id the value.****
>
>  ****
>
> The problem is that ONLY the checked items get passed... if someone is
> "unchecked" their approval is revoked so I need to update the table for
> that as well.****
>
> On Wed, Apr 25, 2012 at 12:18 PM, Brian Marquis <br...@quotepro.com>
> wrote:****
>
> Why not get rid of the hidden field and assign the record id as the value
> of the checkboxes. When you submit the form (or serialize it) only the
> checked items will be passed to the server.****
>
> For example:****
>
>  ****
>
> <input name="ApprovedSubscribers" value="123" type="checkbox"
> checked="checked"/> Joe Cool****
>
> <input name="ApprovedSubscribers" value="456" type="checkbox" /> Fred
> Flintstone****
>
> <input name="ApprovedSubscribers" value="789" type="checkbox"
> checked="checked" /> Barney Rubble****
>
>  ****
>
> Becomes ApprovedSubscribers="123, 789" when submitted.****
>
>  ****
>
> You can then observe the form for changes and submit via ajax with a
> normal form submit for graceful degradation.****
>
> Brian Marquis | Quotepro® | Senior Developer | b...@quotepro.com | Phone: 
> 312.654.8045
> x122 / Fax: 312.654.1285****
>
> [image: image001]****
>
> *The information in this e-mail is confidential and may be legally
> privileged.  It is intended solely for the addressee.   Access to this
> e-mail by anyone else is unauthorized.*****
>
>  ****
>
> *From:* prototype-scriptaculous@googlegroups.com [mailto:
> prototype-scriptaculous@googlegroups.com] *On Behalf Of *Phil Petree
> *Sent:* Wednesday, April 25, 2012 10:39 AM
> *To:* prototype-scriptaculous@googlegroups.com
> *Subject:* [Proto-Scripty] Tactical Advice: Many rows, one checkbox per
> row****
>
>  ****
>
> Hey All,****
>
>  ****
>
> My need is to create a easy approval process for what could be a handful
> of "subscribers" up to 1000's of "subscribers".****
>
>  ****
>
> The idea thus far is to create a table that has (and needs) only a few
> columns of information:****
>
> RecordID (hidden)  |  Approved [checkbox]  |  Subscriber Name (read_only
> text)  |  Subscriber City/State (read_only text)****
>
>  ****
>
> <refrain ad nausem 'x' times>****
>
>  ****
>
> What I want to do is to allow the user to CHECK/UNCHECK the check box and
> that event will call an ajax function that will submit the RecordID and
> Approved box[checked/unchecked]****
>
>  ****
>
> I don't want to submit ALL rows, only the row that was just clicked.****
>
> I'm pretty sure the FormObserver is the wrong way to go****
>
> I'm pretty sure the $('approved').observe('change', xxx); isn't right
> either as that could create 1000's of observers****
>
>  ****
>
> I could do an onchange event for each checkbox... but if I do that, how do
> I serialize two fields of data?****
>
>  ****
>
> Advice please....****
>
>  ****
>
> Pete****
>
>  ****
>
>
>  ****
>
>  ****
>
>  ****
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to
> prototype-scriptaculous@googlegroups.com.
> To unsubscribe from this group, send email to
> prototype-scriptaculous+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.****
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to
> prototype-scriptaculous@googlegroups.com.
> To unsubscribe from this group, send email to
> prototype-scriptaculous+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.****
>
> ** **
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to
> prototype-scriptaculous@googlegroups.com.
> To unsubscribe from this group, send email to
> prototype-scriptaculous+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.****
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to
> prototype-scriptaculous@googlegroups.com.
> To unsubscribe from this group, send email to
> prototype-scriptaculous+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

<<image003.png>>

<<image004.png>>

Reply via email to