I am working on this app, which has a form where you input the name, choose a value from a dropbox, and select one or more items from a checkbox. I need to redirect the values of this form to another page and format them to a table. I am new to programming, and want to get the values from the add form and format them into a table in the tally form. Here are my code snippets:
@app.route('/add', methods=['POST','GET'])
def add():
if request.method == 'POST':
plan_name = request.form
formation_name = request.form
variation_name = request.form
return redirect('/tally')
return render_template('add.html')
@app.route('/tally', methods=['Get','POST'])
def tally():
return render_template('tally.html')
<form action='/add' method='POST'>
<h1>Enter a name for your gameplan:</h1>
<div class="form-group row">
<label for="plan" name = 'plan_name'value = '{{request.form['name']}}' class="col-sm-2 col-form-label">Name:</label>
<div class="col-sm-10">
<input type="text" >
</div>
</div>
<p><h1>Choose Your Formation<p></h1>
<div class="form-row align-items-center">
<div class="col-auto my-1">
<select class="custom-select mr-sm-2" id="inlineFormCustomSelect">
<option selected>Choose...</option>
<option name = "formation_name" >Doubles</option>
</select>
</div>
</div>
<p><h1>Select The Variation</h1></p>
<div class="form-group row">
<div class="col-sm-2">Select one or many:</div>
<div class="col-sm-10">
<div class="form-check">
<input class="form-check-input" name = 'variation_name' type="checkbox" id="split">
<label class="form-check-label" for="split">
Split
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="nearPistol">
<label class="form-check-label" for="nearPistol">
Near Pistol
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="farPistol">
<label class="form-check-label" for="farPistol">
Far Pistol
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="queen">
<label class="form-check-label" for="queen">
Queen
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="right">
<label class="form-check-label" for="right">
Right
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="left">
<label class="form-check-label" for="left">
Left
</label>
</div>
</div>
</div>
<div>
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-primary">Save</button>
</div>
</div>
<div class="form-group row">
<div class="col-sm-10">
<button type="submit" class="btn btn-primary">Add Another Formation</button>
</div>
</div>
</div>
</form>
{%endblock%}
{%for key, values in add %}
<thead >
<tr>
<th scope="col">{{key.formation_name}}</th>
<th scope="col">Left</th>
<th scope="col">Right</th>
</tr>
</thead>
<tbody>
<tr>
<td scope="row">{{values.variation_name}}</td>
<td>
<div class='container'>
<button type="button" class="btn btn-outline-primary">Run</button>
<button type="button" class="btn btn-outline-primary">Pass</button>
</div>
</td>
<td>
<div class='container'>
<button type="button" class="btn btn-outline-primary">Run</button>
<button type="button" class="btn btn-outline-primary">Pass</button>
</div>
</td>
</tr>
</tbody>
{% endfor %}
</table>
<div class="col-sm-10 container">
<button type="submit" class="btn btn-primary">Tally Results</button>
</div>
{%endblock%}