Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Nov. 8, 2005 23:56:29

Chris C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

multiple object form?


this must be possible, but it's escaping me...

How would I go about creating a form that allows me to answer multiple
poll questions on the same page? I'd like my resulting HTML to look
something like

<form....
<table>
<tr>
<td>
What's up <input type="hidden" name="question1"
value="1111">
</td>
<td>
<input type="radio" name="answer1" value="1">The sky
<input type="radio" name="answer1" value="2">Not much
</td>
</tr>

<tr>
<td>
How are you? <input type="hidden" name="question2"
value="2222">
</td>
<td>
<input type="radio" name="answer2" value="3">Very well.
<input type="radio" name="answer2" value="4">Grrrr!
</td>
</tr>
</table>
</form>

I can figure out how to cycle through the questions and answers, but I
can't figure out how to keep track of where I am in the loop to
generate "question1", "question2", etc. I tried putting in {% i = 0
%}, but that gave me an "invalid block tag" error.

Am I on the right track, or is there another pattern I should be
following?

Offline

#2 Nov. 9, 2005 00:25:04

Adrian H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

multiple object form?


On 11/8/05, Chris Curvey <> wrote:
> I can figure out how to cycle through the questions and answers, but I
> can't figure out how to keep track of where I am in the loop to
> generate "question1", "question2", etc. I tried putting in {% i = 0
> %}, but that gave me an "invalid block tag" error.

Check out {{ forloop.counter }} or {{ forloop.counter0 }}
(zero-based). Those variables are automatically available to you
within any {% for %} loop.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org

Offline

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support