> -----Original Message-----
> From: Bryan Stevenson [mailto:[EMAIL PROTECTED]
> Sent: Thursday, December 15, 2005 5:17 PM
> To: CF-Talk
> Subject: AJAX related: onClick grab all form elements
>
> Hey All,
>
> Now that I'm looking into AJAX, I'm wondering how I can grab the values of
> ALL form elements with an onClick event?
>
> I'd like to grab them all as a structure or array and send the FORM scope
> off to a CFC to perform server-side validation and passback the results
> (i.e. avoid the full form post and page refresh as you'd have in normal
> server-side validation).
>
> Hopefully that was clear enough ;-)
You can loop over the form (or all forms) - it's an array.
Then you can use the "type" property of the fields to determine the type
("text", "radio", "select-one", etc.) and extract the information into a new
Object (struct).
Once I get home I could through something together pretty quickly if you get
lost.
Personally for most forms I create a client-side object representing the
form values. When the page is created I instantiate the object (with
default values and such). I use those values to pre-populate the form.
Then I use generic "onchange" functions to keep this object updated. The
field look like this:
<input type="Text" name="Whaddeva" onChange="Page.FieldOnChange(this);">
The onchange function determines (usually from the type) what to do, does it
and then repopulates the form from the object. "Submitting" the form is
actually just serializing the object and posting it up to the server.
It works pretty well for me and nicely separates the display of the form
from the data.
Jim Davis
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:227133
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54