# Get value from a collection\_select

**URL:** <https://www.ruby-forum.com/t/get-value-from-a-collection-select/143276>\
**Category:** Rails\
**Created:** [July 16, 2008, 10:23pm UTC](https://www.ruby-forum.com/t/get-value-from-a-collection-select/143276 "2008-07-16T22:23:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![monsterag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@monsterag](https://www.ruby-forum.com/u/monsterag)\
**Post date:** [July 16, 2008, 10:23pm UTC](https://www.ruby-forum.com/t/get-value-from-a-collection-select/143276/1 "2008-07-16T22:23:23Z")

</div>

Hello,  
how can i get the values of a form that has been filled out but was not  
sent to the database.  
i have a collection\_select formfield and i need the selected item to  
fill an DIV with content specific to the selected item.

In Javascritp iÂ´ve done it in this way:

for (i = 0; i \< document.formular.zeitung.length; ++i)  
if (document.formular.zeitung.options[i].selected == true){  
var textinhalt = document.formular.zeitung.options[i].value;  
}

So in textinhalt the value is stored. How can i achieve this with ruby?

tia
