--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
class Process(webapp.RequestHandler):
def post(self):
self.response.out.write('hello<br />')
data = self.request.get('test[]')
for d in data:
self.response.out.write(d)
class MainPage(webapp.RequestHandler):
def get(self):
self.response.out.write('<html><body>')
self.response.out.write("""
<form action="/process" method="post">
<input type="text" name="test[]" />
<br />
<input type="text" name="test[]" />
<br />
<input type="text" name="test[]" />
<br />
<input type="text" name="test[]" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>""")
self.response.out.write('</body></html>')
The MainPage generates a form with four textboxes, each with name =
"test[]".
Submit sends the output to Process. With php, _POST[test[]] is an array
with four values, the values being the text entered into each of the
test boxes.
In app engine, self.request.get('test[]') apparently only gets the value
of the first text box.
So my question is whether there is a way to have an array of text boxes,
and to retrieve the value of each of them in a list or other data structure.
I know that I can generate the text boxes so that they are names test1,
test2, test3, and test4, and then write code to loop through and build
the text box names, and issue a get for each name, but that seems really
clunky and error prone.
Thanks for any help,
Mike
On 07/26/2010 04:16 AM, Alon Carmel wrote:
> first, it depends on how your working with python on app engine.
>
> django :
> self.request.GET/POST['VARNAME'] or django request.GET/POST['VARNAME']
>
> The .POST or .GET are dictionaries of all the passed data. you can
> also access them via .REQUEST.
>
> For example:
>
> myarray = request.POST['myarray']
>
> for item in myarray:
> //do something
>
> you can also print those arrays to see the structure... dir or print.
>
>
> -
> Cheers,
>
> def AlonCarmel(request)
> import simplejson as json
> contact = {}
> contant['email'] = 'a...@aloncarmel.me <mailto:a...@aloncarmel.me>'
> <mailto:google-a...@googlegroups.com>.
> To unsubscribe from this group, send email to
> google-appengi...@googlegroups.com
> <mailto:google-appengine%2Bunsu...@googlegroups.com>.
On 07/26/2010 04:16 AM, Alon Carmel wrote:
> first, it depends on how your working with python on app engine.
>
> django :
> self.request.GET/POST['VARNAME'] or django request.GET/POST['VARNAME']
>
> The .POST or .GET are dictionaries of all the passed data. you can
> also access them via .REQUEST.
>
> For example:
>
> myarray = request.POST['myarray']
>
> for item in myarray:
> //do something
>
> you can also print those arrays to see the structure... dir or print.
>
>
> -
> Cheers,
>
> def AlonCarmel(request)
> import simplejson as json
> contact = {}
> contant['email'] = 'a...@aloncarmel.me <mailto:a...@aloncarmel.me>'
> <mailto:google-a...@googlegroups.com>.
> To unsubscribe from this group, send email to
> google-appengi...@googlegroups.com
> <mailto:google-appengine%2Bunsu...@googlegroups.com>.