keeping radio button value after post

user1400 picture user1400 · Aug 7, 2010 · Viewed 12.5k times · Source

HI

i'm using a php page and i need to keep the value of and check box and radio button (checked or not checked) after post page.

how could i make it?

thanks

Answer

Naveen picture Naveen · Jun 15, 2012

First get the radio button value.

$radiobuttonvalue = $_POST['radiobuttoname']

Then for each radio button with the same name, do this

<input type="radio" name="radiobuttonname" value="value" id="radiobuttonname" <?php if($radiobuttonvalue == "value") { echo 'checked="checked"';} ?>