Change value from DB after click

How, when you click on a button in a template, change the value of the DB field and display the changed result in the same template. An important point is that everything happens in the same template.How to do this?

It seems Liveview could help You do this.

The template is on the server, but it can be updated when events occurs.

There is a lot of ways to accomplish your goal. Can you provide more information?
On the top of my mind:

  • If you are using usual phoenix templates, route the button to any of your controllers and change the Db’s value there.
  • If you are using javascript, send a XMLHTTP request to an specific route on your app and do the same.
  • as @kokolegorille said, you can use LiveView to get the same result.

If possible, avoid calling the DB from the template.