4
Contributors
8
Replies
9
Views
9 Years
Discussion Span
Last Post by jobykjoseph
0

How to generate dynamic radio buttons in php

<?
$arrX = array('Ben','Sam','Will');
foreach ($arrX as $value) {
	echo "<input type=\"radio\" name=\"RadioGroup1\" value=".$value." />".$value."<br />";
}
?>

CMIIW :)

0

Use <?php instead of <? (very bad habit).

Matti Ressler
Suomedia

I don't think thats the problem. Because, If short tags are disabled on his computer, it will just print the 'code' as text.

0

I don't think thats the problem. Because, If short tags are disabled on his computer, it will just print the 'code' as text.

Well that depends on which browser they are using.


Matti Ressler
Suomedia

0

My actual question was how do i create radio buttons in a loop

for eg:
for($i=0;$i<10;$i++)
{
echo '<input type="radio" name="name[$i]" value=$i>abc';
echo '<input type="radio" name="name[$i]" value=$i>def';
}

how can i select 10 radio buttons out of this 20 buttons ang get the value of these buttons......

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.