On Thu, Mar 5, 2009 at 1:05 AM, [email protected]
<[email protected]> wrote:
>
> Hello
>
> I have
> ${h.select('name', value=1, options=[("1", "name1"), ("2", "name2")]}
>
> In controller i'v use request.POST("name") to get name1 or name2. But
> i need to get value of selected. How to do it?

Where is that select() function being imported from?  It doesn't match
the syntax of webhelpers.html.tags.select() or
webhelpers.rails.form_tags.select().  When I try the former with your
arguments I get "TypeError: select() takes at least 3 non-keyword
arguments (1 given)".  Here's how you do it:

"""
>>> import webhelpers.html.tags
>>> print webhelpers.html.tags.select('name', 1, [("1", "name1"), ("2", 
>>> "name2")])
<select id="name" name="name">
<option selected="selected" value="1">name1</option>
<option value="2">name2</option>
</select>
"""

This would make the browser return name=1 to the application.  If you
want to pass the arguments by name, the second arg is
``selected_values``, not ``value``.  It should properly be a list of
strings, although a string/numeric value is automatically promoted to
a one-element list.

-- 
Mike Orr <[email protected]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to