I am creating radio buttons in run time using a loop and it will select one value of the radio buttons according to the loop in ascending order like:
bana is on first its selected value is "1"
apple is on second its selected value is "2"
orange is on third its selected value is "3"
lemon is on fourth its selected value is "4"
Here is the code of creating radio button count=4
and variable $var
get value from outer loop this loog runs for the second time $var
value will be 2 and so on so that it select the radio option in the pattren display in the pic above
for($i=1;$i<=$count;$i++)
{
$secname=str_replace(" ",'',$data[0]);
if($i==$var)
{
echo("<input type='radio' name='$secname' value='$i' checked='checked'>$i");
}
else
{
echo("<input type='radio' name='$secname' value='$i'>$i");
}
// echo("<input type='hidden' name='rad[]' value='$i'/>");
}
How to swap the radio button value on change such that when i select apple radio value "1" it will change the bana value to "2" interchange its value