bbp
2008-Jan-02 17:21 UTC
[1.5] How to serialize a form containing something else than inputs?
Hi, I''m trying to serialize a form with prototype 1.5. It works well with all input fields but it doesn''t include any field which aren''t input field like select and textarea. This is a sample of the form : -------------------------------------------------------------------------------------------------------------------------------------------------- <p><label for="iIdDroit">ID droit :</label><input type="text" id="iIdDroit" name="iIdDroit" /></p> <p>Droit primaire : <label for="iPrimaireOui">oui</label><input type="radio" id="iPrimaireOui" name="iPrimaire" value="1" /> <label for="iPrimaireNon">non</label><input type="radio" id="iPrimaireNon" name="iPrimaire" value="0" /> </p> <p><label for="listeDroitPrimaire">Droit secondaire :</label> <select id="listeDroitPrimaire"> <option></option> <option value="ScoringAvantEvaluation">ScoringAvantEvaluation</ option> <option value="GestionParticipantsEquipe">GestionParticipantsEquipe</option> <!-- ... --> </select> </p> <p> <label for="insertDroit">Profils :</label> <ul> <li><input type="checkbox" id="insertDroita" name="insertDroit" value="a" /></li> <li><input type="checkbox" id="insertDroitc" name="insertDroit" value="c" /></li> <li><input type="checkbox" id="insertDroitd" name="insertDroit" value="d" /></li> <!--...--> </ul> </p> <p><label for="tDetail">Détail :</label><textarea id="tDetail" rows="2" cols="30"></textarea></p> -------------------------------------------------------------------------------------------------------------------------------------------------- Event.observe("ajouterDroit", "click", function(e) { new Ajax.Request("DroitMaj.asp", { method: "post", parameters: {r:"rtype", d:$("form0").serialize(false)} }); }); -------------------------------------------------------------------------------------------------------------------------------------------------- And i get : r=rtype&d=iIdDroit%3Dsdfdsfsd%26iPrimaire%3D0%26insertDroit %3Dc%26insertDroit%3Dd%26insertDroit%3De or more readable : r=rtype&d=iIdDroit=sdfdsfsd&iPrimaire=0&insertDroit=c&insertDroit=d&insertDroit=e As you can see tDetail and listeDroitPrimaire are not in the string. Can you help me or just explain to me? Thanks, bbp. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Tobie Langel
2008-Jan-02 20:05 UTC
Re: How to serialize a form containing something else than inputs?
Hi, Forms elements need a name attribute to be serialized. Once you add thoe to selects and textareas, you''ll be all set. Best, Tobie On Jan 2, 6:21 pm, bbp <fivestarscleanin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''m trying to serialize a form with prototype 1.5. It works well with > all input fields but it doesn''t include any field which aren''t input > field like select and textarea. > > This is a sample of the form : > > --------------------------------------------------------------------------- ----------------------------------------------------------------------- > <p><label for="iIdDroit">ID droit :</label><input type="text" > id="iIdDroit" name="iIdDroit" /></p> > <p>Droit primaire : > <label for="iPrimaireOui">oui</label><input type="radio" > id="iPrimaireOui" name="iPrimaire" value="1" /> > <label for="iPrimaireNon">non</label><input type="radio" > id="iPrimaireNon" name="iPrimaire" value="0" /> > </p> > <p><label for="listeDroitPrimaire">Droit secondaire :</label> > <select id="listeDroitPrimaire"> > <option></option> > <option value="ScoringAvantEvaluation">ScoringAvantEvaluation</ > option> > <option > value="GestionParticipantsEquipe">GestionParticipantsEquipe</option> > <!-- ... --> > </select> > </p> > <p> > <label for="insertDroit">Profils :</label> > <ul> > <li><input type="checkbox" id="insertDroita" > name="insertDroit" value="a" /></li> > <li><input type="checkbox" id="insertDroitc" > name="insertDroit" value="c" /></li> > <li><input type="checkbox" id="insertDroitd" > name="insertDroit" value="d" /></li> > <!--...--> > </ul> > </p> > <p><label for="tDetail">Détail :</label><textarea id="tDetail" > rows="2" cols="30"></textarea></p> > --------------------------------------------------------------------------- ----------------------------------------------------------------------- > Event.observe("ajouterDroit", "click", function(e) { > new Ajax.Request("DroitMaj.asp", { > method: "post", > parameters: {r:"rtype", d:$("form0").serialize(false)} > }); > }); > --------------------------------------------------------------------------- ----------------------------------------------------------------------- > > And i get : r=rtype&d=iIdDroit%3Dsdfdsfsd%26iPrimaire%3D0%26insertDroit > %3Dc%26insertDroit%3Dd%26insertDroit%3De > or more readable : > r=rtype&d=iIdDroit=sdfdsfsd&iPrimaire=0&insertDroit=c&insertDroit=d&insertD roit=e > > As you can see tDetail and listeDroitPrimaire are not in the string. > > Can you help me or just explain to me? > > Thanks, > > bbp.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
bbp
2008-Jan-03 08:11 UTC
Re: How to serialize a form containing something else than inputs?
Oh yeah, I just forgot them :) Thanks a lot. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---