Вот моя таблица HTML:
Код: Выделить всё
Recipient Name
Contact number
Street name
Category
Actions
{% for address in addressInfo %}
{% if address.15 == 1 %}
Default
{{address.3}}
{% else %}
{{address.3}}
{% endif %}
{{address.11}}
{{address.8}}
{{address.12}}
[i][/i]
[i][/i]
[i][/i]
{% endfor %}
Код: Выделить всё
$(".btn-delete-address").click(function() {
event.preventDefault();
swal({
icon: "warning",
title: "Delete address",
text: "Do you wish to delete this address? You cannot recover this address once deleted.",
type: "warning",
buttons: {
confirm: {
text: "Delete",
className: "btn btn-success"
},
cancel: {
visible: true,
className: "btn btn-danger",
},
},
}).then((deleteValue) => {
if (deleteValue) {
$(".form-delete-address").submit();
};
});
});
Код: Выделить всё
@homepage.route('/deleteBuyerAddress/', methods=['GET', 'POST'])
def deleteBuyerAddress(addressBookID):
if request.method=='POST':
conn = get_db_connection()
if conn is None:
flash("NO DB CONNECTION", category='error')
return redirect(url_for('homepage.home'))
cursor = conn.cursor()
try:
cursor.execute("DELETE FROM address_book WHERE accountID=%s and addressBookID=%s", (session['accountID'], addressBookID))
conn.commit()
flash("Successfully deleted address!", category='success')
return redirect(url_for('homepage.addressBook'))
except Error as e:
conn.rollback()
flash(f"{e}", category='errpr')
return redirect(url_for('homepage.addressBook'))
finally:
cursor.close()
conn.close()
Подробнее здесь: https://stackoverflow.com/questions/792 ... e-last-row