Deepika
Deepika

Reputation: 826

How to disable the default option in dropdown list

I want to disable the default option given in dropdown list. e.g. There are three values in dropdown list

["Select a status", "Processing", "Completed"]

I want to apply disabled and selected properties on "Select a status".

Can you please tell me how to do this? I am not able to use both the properties on same value.

Upvotes: 2

Views: 222

Answers (2)

Salil
Salil

Reputation: 47482

Following works for me

<%= select("post", "person_id", options_for_select(["Free", "Basic", "Advanced", "Super Platinum"], :disabled => "Super Platinum", :selected => "Super Platinum" ))  %>

Upvotes: 1

dbslone
dbslone

Reputation: 2034

Have you tried using options_for_select

<%= select_tag(:city_id, options_for_select(["Free", "Basic", "Advanced", "Super Platinum"], :disabled => "Super Platinum", :selected => "Super Platinum")) %>

Upvotes: 2

Related Questions