How can be selected radio buttons that have a small color rectangle for text label? <form action="" method="get"> <input type="radio" name="preferred_color" value="Red"/> <input type="radio" name="preferred_color" value="Green" /> </form> PHP:
you can use the select feature to make the radio button seleted. <input type="radio" name="preferred_color" value="Green" selected="selected"/> you can try this. If its not working then search from google like" how to make selected a radio button" then you will get easily these example.
First, make a small box next to the radio buttons - a simple 20x20px DIV layer with a unique ID tag. Then, on each radio button, you would have an onClick event handler to call a JavaScript function with the color value and the ID of the target DIV layer as the two arguments. The JavaScript function would look something like this: <HTML> <HEAD> <SCRIPT TYPE="text/javascript"> function changeColor(colorValue, targetDiv) { document.getElementById(targetDiv).style.backgroundColor = colorValue; } </SCRIPT> </HEAD> <BODY> <form action="" method="get"> <input type="radio" name="preferred_color" ID="radioRed" value="#f00" onClick="changeColor(this.value, 'colorDiv');" /> <LABEL FOR="radioRed">Red</LABEL> <input type="radio" name="preferred_color" ID="radioGreen" value="#0f0" onClick="changeColor(this.value, 'colorDiv');" /> <LABEL FOR="radioGreen">Green</LABEL> <DIV ID="colorDiv" STYLE="width: 20px; height: 20px; border: 1px solid #000;"></DIV> </form> </BODY> </HTML> Code (markup): Instead of using "red" and "green", I would use hex octets, but that's my own personal preference. If you do, make sure they are preceded by the hash-tag "#". Hope this helps!