0

Hi,
I have dynamically created radio buttons.

$i=1;
<input type="radio" name="qtn-$i" value="yes">
$i++;

Now how to get the values of these buttons using post method?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by sudeepjd
0

Are you using PHP? 'Cos there is no way our going to get the radio buttons appear on the screen without the echo statement. You code above is going to go into an infinite loop, provided of course you put in a loop statement in the first place.

Also the way you have created the radio buttons with different names, will be in such a way that you can select all the radio buttons at a time.

Enough of my criticism, coming down to the actual code part.

<form method="post">
<?
echo $_POST['qtn'];
for ($i=1;$i<=4;$i++){
	echo "<input type='radio' name='qtn' value='$i'>";
}
?>
<input type="submit">
</form>

The above code is a simple way you can get the values of the radio buttons using a POST method. The name of the radio buttons need to be the same but the value will change.

Please do let me know if you need anything else.

Edited by sudeepjd: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.