I have a bunch on table rows where each row will contain a bunch text inputs. Now below is the name attributes for the possible inputs which contains its own value in each table row:
answerAvalue = A
answerBvalue = B
answerCvalue = C
answerDvalue = D
answerEvalue = E
... //all the way to answerZvalue = Z
answerTruevalue = True
answerFalsevalue = False
answerYesValue = Yes
answerNovalue = No
Each table row also contains some radio buttons which are below:
<input type="radio" name="reply" />= = Single
<input type="radio" name="reply" />= = Multiple
So lets say I go through each table row and retrieve the values of each radio button selected in each row, then the code for this is below:
$i = 0;
$c = count($_POST['gridValues']); //counts number of appended rows
for($i = 0; $i < $c; $i++ ){ //for each loop which goes through each row
switch ($_POST['reply'][$i]){
case "single":
$selected_reply = "Single";
break;
case "multiple":
$selected_reply = "Multiple";
break;
default:
$selected_reply = "";
break;
}
But what my question is that because each text input has its own name attribute, then how can I write the code to achieve the same as above but for obviously for the text inputs?
1 Answer