This is the my index.html
<!DOCTYPE html>
<script>
function add_field()
{
var total_text=document.getElementsByClassName("input_text");
total_text=total_text.length+1;
field_div = document.getElementById("field_div");
new_input = "<li id='input_text"+total_text+
"_wrapper'><input type='text' class='input_text' name='input_text[]' id='input_text"+
total_text+"' placeholder='Enter Text'>"+
"<label><input name='input_text"+total_text+"' id='input_text[]' type='radio' value='1'>1</label>"+
"<label><input name='input_text"+total_text+"' type='radio' id='input_text[]' value='2'>2</label>"+
"</li>";
field_div.insertAdjacentHTML('beforeend',new_input);
}
function remove_field()
{
var total_text=document.getElementsByClassName("input_text");
document.getElementById("input_text"+total_text.length+"_wrapper").remove();
}
</script>
{% extends "bootstrap/base.html" %}
{% block content %}
<div class = "container">
<h1>Give the words</h1>
<form action='/results' method="post">
<div id="wrapper">
<input type="button" value="Add TextBox" onclick="add_field();">
<input type="button" value="Remove TextBox" onclick="remove_field();">
<ol id="field_div">
</ol>
</div>
<input type='submit' value='Select'>
</form>
</div>
{% endblock %}
My views.py is as follows:
from flask import render_template, request, url_for
from app import app
from .translit import *
@app.route('/')
def search():
return render_template('index.html')
@app.route('/results', methods = ['GET', 'POST'])
def results():
if request.method == 'GET':
return redirect(url_for('/'))
else:
values = getperm(request.form.getlist('input_text[]'))
print(request.form.getlist('input_text[]'))
return render_template('results.html',
values = values)
Right now, I can extract the input from all the input texts as a list?
How do I get the values form each <li> as a list thereby creating a list of lists?
As an example, if i type
a 1
b 2
I should be able to extract the result as [[a,1],[b,2]]

