OR IF YOU WANT TO DO THIS YOURSELF...
What I would do would be to create the buttons with the <button>
element and a hidden form field element to remember which one is "pressed" like so:
<button type="button" id="btn1">Choice 1</button>
<button type="button" id="btn2">Choice 2</button>
<button type="button" id="btn3">Choice 3</button>
<input type="hidden" id="btnValue" value="" />
You will CSS to show that the button is "pressed down" or not "pressed down" so you would need them by default to be something like this:
button
{
border-width: 2px;
border-style: outset;
border-color: /*Insert a darker version of your button color here*/
}
Then in jQuery (if you can do it in jQuery, you can do it in straight JavaScript, so keep that in mind if you don't want to use jQuery):
$("#btn1").click(function () {
$(this).css("border-style", "inset")
$("#btn2").css("border-style", "outset;");
$("#btn3").css("border-style", "outset;");
$("btnValue").val("btn1IsPressed");
});
$("#btn2").click(function () {
$(this).css("border-style", "inset")
$("#btn1").css("border-style", "outset;");
$("#btn3").css("border-style", "outset;");
$("btnValue").val("btn2IsPressed");
});
$("#btn3").click(function () {
$(this).css("border-style", "inset")
$("#btn1").css("border-style", "outset;");
$("#btn2").css("border-style", "outset;");
$("btnValue").val("btn3IsPressed");
});
Now all you need to do is request the value from #btnValue
after POST (or GET or whatever), just like you normally would to tell which "button" they had pressed.
Be advised you will need to add a little more functionality to "unpress" the buttons, but I think you get the point. All you would need to do is read the value of #btnValue
on click and, along with your other statements,use an if branch to handle whether it is already pressed or not and switch the borders accordingly (don't forget to clear (""
) the value of #btnValue
on the "unpressing" of a button so you can tell whether they left them all unpressed or not).