On Thu, Feb 5, 2009 at 8:47 PM, min <inuyasha...@gmail.com> wrote:

>
> Ok, Thanks!
>
> Another thing is that: I can only get one value by request.GET
> ['selectM'].strip(), when I select two or more options in the
> SelectMultiple widget.
>
> For example, if I selected 'test1' and 'test2' in the SelectMultiple
> widget, the value in the "request.GET['selectM'].strip()" is only
> 'test2'.
>
> If I want get all the values which I have selected, how to do that?
>
>
>
>
>
> On Feb 6, 12:24 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> > On Thu, Feb 5, 2009 at 8:22 PM, min <inuyasha...@gmail.com> wrote:
> >
> > > Hi.
> >
> > > In the following templates file, we can get the value of zip by using
> > > ' request.GET['zip'].strip()' in the views.py
> > > <html>
> > > <head><title></title></head>
> > > <body>
> > >        <form method="get" action="." >
> > >             Zip<input id="zip"  type="text" name="zip" value='aaa'/>
> > >             <input type="submit"  value="submit" />
> > >        </from>
> > > </body>
> > > </html>
> >
> > > However, if the 'zip' input was changed into a SelectMultiple widget,
> > > like  how to get both the  value and option from that widget.
> >
> > > If use request.GET['selectM'].strip() in the following example, we can
> > > only get the the 'value' of selected item.
> >
> > > <html>
> > > <head><title></title></head>
> > > <body>
> > >        <form method="get" action="." >
> > >               <select multiple="multiple" id="selectM">
> > >               <option value='test1'>bbb</option>
> > >               <option value='test2'>ccc</option>
> > >               <option value='test3'>ddd</option>
> > >              </select>
> > >       <input type="submit"  value="submit" />
> > > </from>
> > > </body>
> > > </html>
> >
> > > Is there any way to get both value and text from the SelectMultiple
> > > widget the in the views.py?
> >
> > > thanks
> >
> > I don't believe so, the way HTTP works with the browser is that it only
> > POSTs the value, fyi you might want to look at django.forms since it
> saves
> > you from worrying about this stuff.
> >
> > Alex
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
> >
>
request.GET.getlist('field') returns a list with all the values.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to