Prototype Form.serializeElements

35 views
Skip to first unread message

Neede

unread,
Dec 22, 2009, 11:27:25 AM12/22/09
to Prototype & script.aculo.us
Hello,

I've run into a response performance problem with IE6. My form has a
4 scrollable tables that each contain up to 2000 check boxes (names:
typeA, typeB, typeC, typeD). serialize() is taking a long time to
process, so i was attempting to speed it up by only serializing the
check boxes that I need by using:

Form.serializeElements( $("frm").getInputs('checkbox', "typeA"),
true);

this works fine but i also want to serialize typeB and typeC. I need
everything but typeD which happens to have the the greatest number of
checkboxes.

I tried creating an array for the check box names
arChkBoxes = [ "typeA", "typeB", "typeC"];
var params = Form.serializeElements( $("frm").getInputs('checkbox',
arChkBoxes ), true);

Any help on the correct syntax or ideas on how to speed up the
serialization is appreciated!

Al C

unread,
Dec 24, 2009, 8:58:48 AM12/24/09
to Prototype & script.aculo.us
How 'bout something like
var paramsA = Form.serializeElements( $("frm").getInputs('checkbox',
"typeA"),true);
var paramsB = Form.serializeElements( $("frm").getInputs('checkbox',
"typeB"),true);
var paramsC = Form.serializeElements( $("frm").getInputs('checkbox',
"typeC"),true);

var params = paramsA + '&' + paramsB + '&' + paramsC;

Yeah... I know it's not as sexy as defining the array and running
through an 'each' loop but I bet it would work :-)

(With string concatenation, you could, of course, do it all in a
single variable)

Al

Reply all
Reply to author
Forward
0 new messages