Value of a list

Hi all,

I am a newbie. Those are little technical questions that will look
simple to me after a little while. But for the moment I am stuck.

I have a select list which I use to list the a marees table
<%= select 'clim', 'maree_id', @marees.collect {|c| [c.nom,]} %>

I would like to create a link edit which would link to the edit page
of the selected row of the list.

would you be so kind and give me an hint ?


First, I'd use the method collection_select, because then you don't
have to hassle with the collect call yourself.

As for your problem, you're going to have to use javascript for that.
You'll have to change the edit link whenever the dropdown changes. As
an HTML option, pass

:onchange => "update_link('id_of_link')"

and put a script in your view like:

<script type="text/javascript">
  function updateLink(link) {

You'll have to find the nodes in link in which the relevant info is.
I'm not too experienced with javascript, so I can't help you there
without trying it first.

It's easier to just make a form, in which you select what you want to
edit, and then press the edit button.

I am going to use collection_select as you advise.

This list is alreay in a form : _form.rhtml

<p><label for="clim_themodel_id">2-Model</label>
<%= select 'clim', 'themodel_id', @themodels.collect {|c| [c.nom,]} %>

How would I do a form around that so poeple can edit what they have
choosen ?

Thank you.

First, as an exercise in Javascript, I decided to program it: