Hi everyone,
I'm using the serialize function to grab data from a form. Later on,
I want to reverse this from the object and fill the form with the
object data.
I'm surprised there isn't a deserialize or unserialize function in
prototype -- anyone know why this isn't here? How hard would it be to
get something like this this into prototype? This is the code that
I'm using (use at your own risk).
function deserialize(formelement, objectdata) {
keys = Object.keys(objectdata);
inputs = $(formelement).getElements();
keys.each(function(key){
inputs.each(function(input) {
if (input.name == key) {
input.value = objectdata[key];
if (input.type == 'checkbox') input.checked=objectdata[key];
}
});
});
}
Cheer,
Justin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---