On Mon, Feb 22, 2016 at 12:08 PM, Xristos Xristoou <saxr...@gmail.com> wrote:
> the problem in the html form we need to change second input to > take multiple values,for example first input take a number > and the second input take many numbers..if the first number = 2 then take > second input two numbers,two fields for input i try this but not work > > orm action="" method="POST">{% csrf_token %} > Number of number: <input type="integer" name="total_inputs" > value="Number"/> > <button type="submit" class="btn btn-default">calc</button> > {% for i in total_inputs %} > Enter a value: <input type="integer" name="num" value="Total > value"/> > <button type="submit" class="btn btn-default">calc</button> > {% endfor %} > </form> > show me error in the {% for i in total_inputs %} > Why would you ask how many values that a user is going to provide? Why not just count them after the user provides them? Are they providing them in a single input, or are you trying to add multiple input fields, one for each number? For a workflow like that, you should probably look at django-formtools, which includes form wizards for multi-page forms (page 1 asks how many values, page 2 provides X number of fields inputs given on page 1, etc.). Or you need to amend the form dynamically using JavaScript. That gets really tricky though. Is this math formula something you can convert to JavaScript and perform entirely in the client browser? I would go that route and not even bother with trying to have Django process the forms and compute a result. -James -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciU93ug1peo92X%3Dwu3DHFuci%2BSSyQa7JVthtXBKA21r9mg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.