What is the correct way to use an onchange inside a <select> of a <%= form_remote_tag %> block ? When i do <select name=field onchange="this.form.submit()"> it does not update the DOM element, but posts to a new page. A normal submit button however works. Is there a proper way to have this form_remote submit with an onchange ? thanks adam
I had the same problem. My rather ugly workaround was to put the form submit button inside a hidden div and have the onchange click the button. I remember reading another way of doing it too, but cant remember what. Paul On 11/8/05, Adam Denenberg <adam-fpx97dFL/ODYtjvyW6yDsg@public.gmane.org> wrote:> > What is the correct way to use an onchange inside a <select> of a <%> form_remote_tag %> block ? > > When i do <select name=field onchange="this.form.submit()"> it does not > update the DOM element, but posts to a new page. A normal submit button > however works. Is there a proper way to have this form_remote submit > with an onchange ? > > thanks > adam > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I resolved this problem in a rails app, it''s not pretty but I didn''t find a better solution ;) <select name="actions" onchange="document.getElementById(''submitchangeitem'').click();"> <option value="1">1</option> </select> <input type="submit" id="submitchangeitem" value="Change!" /> Hope it helps! 2005/11/8, Paul Rogers <pmr16366-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> I had the same problem. My rather ugly workaround was to put the form submit > button inside a hidden div and have the onchange click the button. > I remember reading another way of doing it too, but cant remember what. > > Paul > > > > On 11/8/05, Adam Denenberg <adam-fpx97dFL/ODYtjvyW6yDsg@public.gmane.org> wrote: > > What is the correct way to use an onchange inside a <select> of a <%> > form_remote_tag %> block ? > > > > When i do <select name=field onchange="this.form.submit()"> it does not > > update the DOM element, but posts to a new page. A normal submit button > > however works. Is there a proper way to have this form_remote submit > > with an onchange ? > > > > thanks > > adam > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
that worked thanks. i did it like this <select onchange="document.getElementById (''submit_location_id'').click();" id=location_id name=location_id> . . . <span style="display:none;"><input type=submit id=''submit_location_id''></span> On Nov 8, 2005, at 6:26 PM, Bruno Celeste wrote:> I resolved this problem in a rails app, it''s not pretty but I didn''t > find a better solution ;) > > <select name="actions" > onchange="document.getElementById(''submitchangeitem'').click();"> > <option value="1">1</option> > </select> > <input type="submit" id="submitchangeitem" value="Change!" /> > > Hope it helps! > > 2005/11/8, Paul Rogers <pmr16366-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> I had the same problem. My rather ugly workaround was to put the >> form submit >> button inside a hidden div and have the onchange click the button. >> I remember reading another way of doing it too, but cant remember >> what. >> >> Paul >> >> >> >> On 11/8/05, Adam Denenberg <adam-fpx97dFL/ODYtjvyW6yDsg@public.gmane.org> wrote: >>> What is the correct way to use an onchange inside a <select> of >>> a <%>>> form_remote_tag %> block ? >>> >>> When i do <select name=field onchange="this.form.submit()"> it >>> does not >>> update the DOM element, but posts to a new page. A normal submit >>> button >>> however works. Is there a proper way to have this form_remote >>> submit >>> with an onchange ? >>> >>> thanks >>> adam >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails