How to disable a item of select box

Hi

I want to disable only one item of select box.

I tried to used :disabled=>‘item’ but it disable select box itself.

So anybody how to do this?

Thanks
Brijesh S.

Brijesh S. wrote:

Hi

I want to disable only one item of select box.

I tried to used :disabled=>‘item’ but it disable select box itself.

So anybody how to do this?

Thanks
Brijesh S.

Hi Brijesh,

I hope the following example would help you… If not put your code
here…

Example:

select(“post”, “category”, Post::CATEGORIES, {:disabled =>
‘restricted’})

could become:

joke poem restricted

I hope the following example would help you… If not put your code
here…

Example:

select(“post”, “category”, Post::CATEGORIES, {:disabled =>
‘restricted’})

could become:

joke poem restricted

Thanks for your reply…

But this code does not work…there is no effect on select box.

if I tried this, select(“post”, “category”, Post::CATEGORIES,{},
{:disabled =>
‘restricted’}) then select box is disabled rather than one item…

read rails doc,there is one noticed thing.

{:disabled =>‘restricted’} is valid hint
'restrcted’must be select value,can imply disabled function.

eg:
<%= select(“message”, “id”, Message.all.collect {|p| [ p.title, p.id
]
}, { :disabled => 16 })
%>

and view render code:

test select disabled values

第一

第二 第三

2009/11/2 Brijesh S. [email protected]

tommy xiao wrote:

read rails doc,there is one noticed thing.

{:disabled =>‘restricted’} is valid hint
'restrcted’must be select value,can imply disabled function.

eg:
<%= select(“message”, “id”, Message.all.collect {|p| [ p.title, p.id
]
}, { :disabled => 16 })
%>

and view render code:

test select disabled values

第一

第二 第三

2009/11/2 Brijesh S. [email protected]

Thanks for help…

Actually I tried with :disabled =>“16” instead of 16
and thats why I did not get result…

Now it works fine…

Brijesh S. wrote:

Hi

I want to disable only one item of select box.

I tried to used :disabled=>‘item’ but it disable select box itself.

So anybody how to do this?

Thanks
Brijesh S.

Hi Brijesh,

As per your need, i think you want to disable particular item from
select box.
so here is the solution,

<%= select(:record, :property_id, Property.all.collect {|p| [ p.name,
p.id ] }, :disabled => 2 [it’s the id which you want to disable] ) %>

Hope this will help you.

Thanks,
Priyanka P.