in

Removing radio button from row data control


I have a form with a table inside which shows the results of a database query. That table has a radio control and two buttons: one for edit, another for delete. In order for me to modify a row, I have to select the radio of the corresponding row and then press either “delete” or “edit” button. What I want to do is to remove that radio button and make the buttons take me straight to editing the corresponding row. When I remove the radio button (it’s kind of obvious) every buttom from every row only take me to edit/delete the first result.

This is my form:

<form method="POST" id="form2" action="{{ url_for('edit_or_delete') }}">

        <table class="table" id="tableSelect">
            <tr>
                <th></th>
                <th>Manejar</th>
                <th>Cantidad</th>
                <th>Concepto</th>
                <th>Fecha</th>
                <th>Updated</th>
            </tr>

            <!-- loop for results -->
            {% for s in mov %}
            <tr><label for="id"></label>
                <td class="center-align"><input type="radio" name="id" value="{{ s.id }}" required></td>
                <td>
                    <button type="submit" name="choice" value="delete" class="btn btn-danger">Borrar</button>
                    <button type="submit" name="choice" value="edit" class="btn btn-primary">Editar</button>
                </td>
                <td>${{ s.cantidad }}</td>
                <td>{{ s.concepto }}</td>
                <td>{{ s.fecha }}</td>
                <td>{{ s.udpated }}</td></label>
            </tr>
            {% endfor %}
        </table>
<!-- end form-group -->
        </form>

This is my route:

@app.route('/edit_or_delete', methods=['POST'])
def edit_or_delete():
    id = request.form['id']
    choice = request.form['choice']
    movs = Movs.query.filter(Movs.id == id).first()
    # two forms in this template
    form1 = AddRecord()
    form2 = DeleteForm()
    return render_template('edit_or_delete.html', movs=movs, form1=form1, form2=form2, choice=choice)



Source: https://stackoverflow.com/questions/70554016/removing-radio-button-from-row-data-control

code wrapper for searching functionality

A simple tool to connect to the network using Tor