1. Have a prompt like "Select a Value" ( selected by default )
I tried this but did not work:
<%= select_tag :current_course,
options_for_select( Course.find(:all).map {|p|
[p.title,p.id]} ),
{ :prompt => "Select a Value" }
%>
I do the find in the controller and feed the options_for_select two instance
variables: the options collection and the selected value.
e.g. select_tag(:priority, options_for_select(@courses, @selected_course))
@courses is just an array so you just put your "Select a Value" as the first
entry.
e.g., @courses = [["Select a Value", "Select a Value"]]
Then push the results of the find onto @courses.
> 2. Generate a 'selected' event so that some action can be done like
submit the form or refresh the page?
If I understand your question, you'll want to use observe_field on the
select_tag. It will fire an Ajax call back to the server when the value in
the select changes.
1. Have a prompt like "Select a Value" ( selected by default )
I tried this but did not work:
<%= select_tag :current_course,
options_for_select( Course.find(:all).map {|p|
[p.title,p.id]} ),
{ :prompt => "Select a Value" }
%>
I do the find in the controller and feed the options_for_select two
instance
variables: the options collection and the selected value.
e.g. select_tag(:priority, options_for_select(@courses,
@selected_course))
@courses is just an array so you just put your "Select a Value" as the
first
entry.
e.g., @courses = [["Select a Value", "Select a Value"]]
Then push the results of the find onto @courses.
> 2. Generate a 'selected' event so that some action can be done like
submit the form or refresh the page?
If I understand your question, you'll want to use observe_field on the
select_tag. It will fire an Ajax call back to the server when the value
in
the select changes.
HTH,
Bill
Hey Bill
Thanks for the help. I could get the "prompt" in my selection list. I
havent tried observe_field yet but will give that a shot. Thanks again -
AJ