Forum: Ruby on Rails Auto refreshing a page based on select change

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Daniel Berger (Guest)
on 2006-01-06 21:00
(Received via mailing list)
Hi all,

I have a select helper form on a web page which contains a list of
dates.  When
the user selects a date, one of the other forms on the page needs to be
updated
based on the newly selected date.

Is there a way to catch this event in Rails?  Are we talking Ajax here?
Or is
there a simpler way?

Thanks,

Dan
C8a634a01a2c4508360874bff7fb1a7f?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-01-06 21:22
Daniel Berger wrote:
> Hi all,
>
> I have a select helper form on a web page which contains a list of
> dates.  When
> the user selects a date, one of the other forms on the page needs to be
> updated
> based on the newly selected date.
>
> Is there a way to catch this event in Rails?  Are we talking Ajax here?
> Or is
> there a simpler way?
>
> Thanks,
>
> Dan

You could use a 'onchange()' script with your select dropdown and
postback a parameter that updates the other field.

Not too difficult, but not as slick as an AJAX solution.
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Daniel Berger (Guest)
on 2006-01-06 22:52
(Received via mailing list)
Kevin Olbrich wrote:
>>Is there a way to catch this event in Rails?  Are we talking Ajax here?
>
> Not too difficult, but not as slick as an AJAX solution.

Thanks Kevin, but I'm not sure how that should look exactly.

<%=
select(:var, :attr, choices, :options => {:onchange => <create new
select here> })
  %>

I'm having trouble following the docs.  Please help.

Thanks,

Dan
C8a634a01a2c4508360874bff7fb1a7f?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-01-06 23:24
6828ffc79486cd2442714bf32286a910?d=identicon&s=25 Vivek Krishna (Guest)
on 2006-01-12 05:32
(Received via mailing list)
On 1/7/06, Kevin Olbrich <kevin.olbrich@duke.edu> wrote:
> > Is there a way to catch this event in Rails?  Are we talking Ajax here?
> > Or is
> > there a simpler way?
> >
> > Thanks,
> >
> > Dan
>
> You could use a 'onchange()' script with your select dropdown and
> postback a parameter that updates the other field.


Why cant you do Ajax.updater () for the onchange() event? That would be
AJAX
right ?
There is an example at
http://www.roryhansen.ca/?p=9
which uses the observer but I was thinking why not use the onchange
insted
of the observer?

Not too difficult, but not as slick as an AJAX solution.
9e0d0ef931e20da15e25a4adf1e78d24?d=identicon&s=25 Matthew (Guest)
on 2006-01-16 15:06
Thanks Kewin!!

Your link:
> http://www.faqs.org/docs/htmltut/forms/_SELECT_onChange.html

helped me solve a problem that's I've been trying to fix since before
christmas. Nice one.
This topic is locked and can not be replied to.