i trying this code these code in html like.
<div class="button-container">
<form action="/get_Exp" method="GET">
<button onclick="getData()">Get Selected Values</button>
</form>
</div>
and in flask like this
@app.route('/web_page_1')
def web_page_1():
global table_html
soup_web = BeautifulSoup(table_html, "html.parser")
# print(soup_web)
# get a reference to the table element
table = soup_web.table
# loop through each row and add a checkbox input element
for i, row in enumerate(table.find_all("tr")[1:]):
if row is not None:
cell = soup_web.new_tag("td") # create a new td element
checkbox = soup_web.new_tag("input",type="checkbox",value=i,
id=f'checkbox_{i}') # create a new input element with type="checkbox" and id custom id
cell.append(checkbox) # add the checkbox to the new td element
row.append(cell) # add the new td element to the end of the row
global table_html_add_checkbox
table_html_add_checkbox = str(soup_web)
return render_template('web_page_1.html', table_html=table_html_add_checkbox)
@app.route('/get_Exp', methods=['GET'])
def get_Exp():
checkbox_values = request.form.getlist('checkbox')
print(checkbox_values)
return "Get Submitted successfully Run!"
but i am getting empty list. i also try this checkbox = soup_web.new_tag("input", type="checkbox", id=f'checkbox_{i}',attrs={'name':'checkbox'})
Aucun commentaire:
Enregistrer un commentaire