conditional form element

I have a button option in my form with 2 options. User may only select one of the options. Based on the option they choose I want an associated select list to appear. I'm guessing this can only be done with javascript or can it be done with just Ruby ?

TIA Stuart

In case this wasn't clear I wanted to elaborate a little more. The user would choose from either an "annual" or "hourly" option. Based on that there would be a list listing dollar amounts. When I first built the amounts table there was a secondary id column , where id-1 was annual and id-2 was hourly. Anyway, I guess this is a javascript thing but then would the whole template need to be a rjs ? Also if there are any pure Ruby options to accomplish this , that would be better.

TIA Stuart

Why not use Ajax? You could use form_remote_tag to make the annual and hourly buttons into forms (independent of your main form) (iirc you can't nest forms).

You could then wrap the dollar-amount-selector (and a hidden annual-or-hourly text field, if needed) in a div and have the contents of that div replaced by the server whenever the annual or hourly buttons were clicked.

(Yes it is all javascript behind the scenes, but javascript which has already been written.)

Hope it helps,

Regards

Chris.

Why not use Ajax? You could use form_remote_tag to make the annual and hourly buttons into forms (independent of your main form) (iirc you can't nest forms).

I don't believe there is a reason couldn't nest forms.

You could then wrap the dollar-amount-selector (and a hidden annual-or-hourly text field, if needed) in a div and have the contents of that div replaced by the server whenever the annual or hourly buttons were clicked.

This would still show up within the main form ? And do I move everything to a RJS template ?

Stuart