# Select tags

**URL:** <https://www.ruby-forum.com/t/select-tags/174074>\
**Category:** Rails\
**Created:** [August 20, 2009, 1:18pm UTC](https://www.ruby-forum.com/t/select-tags/174074 "2009-08-20T13:18:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [August 20, 2009, 1:18pm UTC](https://www.ruby-forum.com/t/select-tags/174074/1 "2009-08-20T13:18:15Z")

</div>

Hello,

Is dere any way to give default value or value to select tags …  
My scenario is:-

\<% value\_array = [1, 2, 3, 4, 5] %\>  
  
\<%= options\_for\_select (value\_array) %\>

Now i am storing these values in database… But after storing value i do  
not know how to show those values in my DDL(Drop down list)…  
like i stored value 4 in database regarding to this DDL. And now i want  
this value 4 as the selected value in my DDL…

Hope you all people got my point …

I am doing it like this:-  
\<% value\_array = [1, 2, 3, 4, 5] %\>  
  
\<%= options\_for\_select (value\_array) %\>

Want to know every possible solution … 🙂

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [August 20, 2009, 1:38pm UTC](https://www.ruby-forum.com/t/select-tags/174074/2 "2009-08-20T13:38:29Z")

</div>

On Aug 20, 12:18 pm, Hemant B. \<rails-mailing-l…@andreas-  
[s.net](http://s.net)\> wrote:

> Hello,
> 
> Is dere any way to give default value or value to select tags …  
> My scenario is:-
> 
> \<% value\_array = [1, 2, 3, 4, 5] %\>  
>   
> \<%= options\_for\_select (value\_array) %\>

Read the docs for options\_for\_select

Fred

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [August 20, 2009, 2:04pm UTC](https://www.ruby-forum.com/t/select-tags/174074/3 "2009-08-20T14:04:13Z")

</div>

Thanks for reply …  
already read …

Is dere any type of mishappening is happening … I mean if i am storing  
values in array as string …

> > Is dere any way to give default value or value to select tags …  
> > My scenario is:-
> > 
> > \<% value\_array = [1, 2, 3, 4, 5] %\>  
> >   
> > ï¿½ \<%= options\_for\_select (value\_array) %\>
> 
> Read the docs for options\_for\_select
> 
> Fred

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [August 20, 2009, 4:45pm UTC](https://www.ruby-forum.com/t/select-tags/174074/4 "2009-08-20T16:45:13Z")

</div>

On Aug 20, 1:04 pm, Hemant B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Thanks for reply …  
> already read …

And you didn’t notice that the second parameter to options\_for\_select  
is the value to be selected ? (you do need to ensure that the type of  
the selected value is the same as the type of the select options - a  
common mistake is for one to be an integer and the other a string)

Fred
