Monday, 12 August 2013

Rails: value of selection tag different from value

Rails: value of selection tag different from value

This one is a bit tricky. I have copied/pasted a with all the countries in
the world, with their id as values. So this is raw HTML, no Rails tag.
I want that, when I edit, the page display the right <option>, but I can't
seem to find something that works.
If there is a way to convert my HTML in a Rails tag (using a hash
{countryId => country} maybe), I'll take it !
This is what I'm currently trying, but isn't working.
<select id="countries" name="pokemon[country]"
onload="setOptions(document.formName.elements['pokemon[country]'].options[document.formName.elements['pokemon[country]'].selectedIndex].value);">
<option value="AF">Afghanistan</option>
<option value="AX">Åland Islands</option>
</select>
Thanks in advance !

No comments:

Post a Comment