Select tags and variables

Is there a way to make pass a variable into a select tag so that the
prompt would show that value.

In other words if my select was being pulled from a table could I say
something like this:

@mystate = “New York”

select(:state, :id @states, :prompt => @mystate)

Any possibility ?


On Sat, 2006-09-30 at 11:11 -0600, Dark A. wrote:

Any possibility ?

if your controller does something like…
@my_model.state = “New York”

then your select already has the default value

If you do a collect for @states, you still have a selection list but
with a default value already entered…


<%= options = [[‘Select’, ‘’]] + @states.collect {
|st| [st.list_value] }
select ‘my_model’, ‘state’, options %>


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs