I'm working on a webapplication for parents to take care of their newborn. I have three buttons for each task, like a progressflow which will show how far in a given task they have been educated (such as three steps for diaper change (Instructed > Done with help > Done by myself)). When a button is clicked it will change color to indicate that this step has been completed.
Now to the question; The parents will have to log in to be able to see this "checklist" and click the buttons. Say that the first time they click the button where they've been instructed, the color change. But the next time they log in to proceed in the "checklist", they'll still see that the "instructed" button has been clicked.
Here's a picture how the checklist looks like unclicked
Here's a picture how the checklist looks like with some clicked options.
The code for the buttons:
<div class="container" id="checkcontainer">
<h2>Diaper change</h2>
<input type="button" value = "Instructed" style= "color:black" onclick="setColor(this)";/>
<input type="button" value = "Done with help" style= "color:black" onclick="setColor(this)";/>
<input type="button" value = "Done by myself" style= "color:black" onclick="setColor(this)";/>
</div>
The script to change the color (sorry for the bad format):
function setColor(element) {
if(!element.hasAttribute('data-count')){
element.setAttribute('data-count', 1);
}var count = element.getAttribute('data-count');
if(count == 0){
element.style.backgroundColor = '#ffffff';
element.setAttribute('data-count', 1);
} else{
element.style.backgroundColor = '#7fff00';
element.setAttribute('data-count', 0);
}
}
I want the chosen option to be stored in my phpmyadmin (MySQL) database, for the parents to see the buttonchange for the next time. Any ideas how the code might look like to store this in my database AND also show it for the next time?