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 | QuoteproR | Senior Developer | <mailto:[email protected]>
[email protected] | Phone: 312.654.8045 x122 / Fax: 312.654.1285
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: [email protected]
[mailto:[email protected]] On Behalf Of Phil Petree
Sent: Wednesday, April 25, 2012 2:01 PM
To: [email protected]
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 <[email protected]> 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 | QuoteproR | Senior Developer | <mailto:[email protected]>
[email protected] | Phone: 312.654.8045 x122 <tel:312.654.8045%20x122> / Fax:
312.654.1285
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: [email protected]
[mailto:[email protected]] On Behalf Of Phil Petree
Sent: Wednesday, April 25, 2012 10:39 AM
To: [email protected]
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
[email protected].
To unsubscribe from this group, send email to
[email protected].
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
[email protected].
To unsubscribe from this group, send email to
[email protected]
<mailto:prototype-scriptaculous%[email protected]> .
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
[email protected].
To unsubscribe from this group, send email to
[email protected].
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.
<<image004.png>>
<<image003.png>>
