I have a system where people can add roles and remove roles from a list (This is what it looks like: https://s7.gifyu.com/images/idea9b50431c2edc0295.gif ) but want a way to save that data when the user clicks "Save". I was thinking I could use JS to get the contents of the ul and run a python function to save the data, but I can figure out how to do it. I've tried Passing data from javascript into Flask and Python Flask calling functions using buttons but couldn't get it working. The problem with the second one is that I couldn't pass data into the function.
This is the code for the ul:
<ul class="role_box_roles" id="rbroles">
{% for role in modroles %}
<li class="role_box_role" style="border-color: rgb(255, 255, 255);">
<button class="role_remove_button" onclick="remove_option('{{role}}', this)" type="button" style="background-color: rgb(255, 255, 255);">-</button>
<span>{{role}}</span>
</li>
{% endfor %}
<li id="plusbutton"><button class="role_add" type="button" onclick="show_options()">+</button></li>
</ul>
I am trying to save the role names ({{role}}).
The save button is below the ul
<div id="save_changes_button" class="save_changes_button" onclick="">Save</div>
I'm trying to save it in a dict stored in the flask file (the python file that is running flask/the website)
I can give extra information if it's required.