App Engine (Python) - POST'ing responses from HTML control arrays
Using App Engine (Python), I am trying to POST the values from a variable array of select controls in an HTML form. Each select control is paired with some text about what the user is rating.
For example, "Rate these fruits from 1-5 (1 least, 5 best)", the user is presented with a dynamic form like -
<> Apple
<> Bananas
<> Cherries
where <> represents an HTML select control (named "fruit_value") where they can choose 1,2,3,4 or 5 for each fruit.
I can return the value of each select control in the POST by using:
fruit_value = self.request.POST.getall('fruit_value')
for fruit_value_score in zip(fruit_value):
print '%s<br />' % (fruit_value_score)
But how do I know which fruit in the array is being scored? I would like to return the text that matches the select control back to the server side. I tried converting the HTML text to an array of named labels but they don't seem to pass their values in the POST. I also tried a hidden txt control but I can't seem to set the value parameter dynamically inside the for..loop when my page builds. I also tried putting the fruit name into an array of disabled txt boxes but that makes the value not passable in the code (otherwise would be passable if not disabled)
Am I missing something obvious here (how to pass the score along with item being scored?)
Many thanks in advance.
Using App Engine (Python), I am trying to POST the values from a variable array of select controls in an HTML form. Each select control is paired with some text about what the user is rating.
For example, "Rate these fruits from 1-5 (1 least, 5 best)", the user is presented with a dynamic form like -
<> Apple
<> Bananas
<> Cherries
where <> represents an HTML select control (named "fruit_value") where they can choose 1,2,3,4 or 5 for each fruit.
I can return the value of each select control in the POST by using:
fruit_value = self.request.POST.getall('fruit_value')
for fruit_value_score in zip(fruit_value):
print '%s<br />' % (fruit_value_score)
But how do I know which fruit in the array is being scored? I would like to return the text that matches the select control back to the server side. I tried converting the HTML text to an array of named labels but they don't seem to pass their values in the POST. I also tried a hidden txt control but I can't seem to set the value parameter dynamically inside the for..loop when my page builds. I also tried putting the fruit name into an array of disabled txt boxes but that makes the value not passable in the code (otherwise would be passable if not disabled)
Am I missing something obvious here (how to pass the score along with item being scored?)
Many thanks in advance.
No comments:
Post a Comment