vendredi 11 décembre 2020

Python Flask getlist of checkboxes returns empty list

I am using an html table to display some data with checkboxes as the first column, so the user can select multiple rows and delete them simultaneously. The html code to create the checkboxes is this:

<td>
    <input type="checkbox" name="checkbox"
        value=>
    
</td>

I'm trying to get a list of all the indexes of the selected rows, so I can pass them on to a function which will delete the rows from the database. Currently I'm just using these two lines to get the list, but I get an empty list every time:

    print(request.form.getlist('checkbox'))
    return 'Done'

Do I have a stupid mistake somewhere? PS. I have almost the entire html doc on one form, because it's a quite simple page and just makes things easier.




Aucun commentaire:

Enregistrer un commentaire