Auto refreshing a page based on select change


#1

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


#2

Daniel B. 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.


#3

Kevin O. 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 => })
%>

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

Thanks,

Dan


#4

Take a look at this…

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


#5

On 1/7/06, Kevin O. removed_email_address@domain.invalid 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.


#6

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.