<!DOCTYPE html>
<html><body>
<p id="myP">This is a paragraph.</p> // txt paragraph
<button type="button" onclick="myFunction()">Small</button> // button one
<button type="button" onclick="myFunction2()">Bigger</button> // button two
<button type="button" onclick="myFunction3()">Large</button> // button three
<script>
function myFunction() { // functon to first button
document.getElementById("myP").style.fontSize = "x-small";
}
</script>
<script>
function myFunction2() {// functon to second button
document.getElementById("myP").style.fontSize = "x-large";
}
</script>
<script>
function myFunction3() { // functon to third button
document.getElementById("myP").style.fontSize = "xx-large";
}
</script>
</body>
</html>
For neatness i'd update the scripts first to take a variable, that way you only need to write it once something like
<button type="button" onclick="myFunction('small')">Small</button>
<button type="button" onclick="myFunction('bigger')">Bigger</button>
then when writing your function employ something like AJAX to push the selected option to another page that simply reads in a post variable and pushes to mysql
<script>
function myfunction(fontSize){
$.ajax({
url: '/some/url',
type: 'POST',
data: { var1: fontSize } ,
contentType: 'application/json; charset=utf-8',
success: function (response) {
// reload items on page if required;
},
error: function () {
// do something with your error
}
});
}
</script>
In your URL you enter on the url line just handle a post variable then add the details into mysql in whatever way you tend to use. You can also put things like CRF_Tokens into the request for a bit more security.
I am assuming you also have a user account or something that may need to be posted along with the variable, this can be handled the same way just append extra items to data separated by a comma i.e.
data: { var1: fontSize, var2: userId, var3: csrfToken }
NOTE: You will need jquery added to your code for ajax to work, and an understanding of AJAX, head to: http://api.jquery.com/jquery.ajax/ for more info