php - Best way to code a big one-click toggle button to replace a single checkbox and submit button form? -


I have a page that contains a simple check box form, with the submit button that allows the user "To play desired."

Looking at the simplicity, I would like to replace it with a DIV and a toggle button or a graphic of something, so that users can click to mark it, but Do not bother with silly single checkbox and submit buttons That is ugly.

I can think that the brief and quick solution is like a link to the solution

Markme.php? Id = XYZ and user = 123

pops the flag into that database for that user, and then redirects back to the page they were viewing.

Would it be appropriate? Is there a better way?

/ I have an enthusiastic start

make it a & lt ; Button & gt; Has an onclick event, which makes an AJAX request to submit requests to some page handlers that will make the database or similar updates, and the successful completion changes its CSS style. , It is pressed.

, use jQuery for, and the buttons should work to look indifferent.

  & lt; Button type = "button" id = "btn play" & gt; Play & lt; / Button & gt;  

then:

  $ ("# btnplay"). Click (function () {var button = $ (this); if (! Hackles ('pressed')) // // unrestricted $ .post ("ajax.php", {userId: "5512", action: "Play"}, function {button.addClass ('pressed'); Button.html ("playing!"}}}} Other {// button pressed, return it to $. Toggle ("ajax.php", {userId: "5512", verb: "stopplaying"}, function (data) {button.removeClass ('pressed'); button.html ("Play");}); }});  

Comments