Hi

I am working on a project that, in short, builds up a form dynamically based on spcific 'keys' found in data retrieved from a database.

Now, I need to get ALL form fields to post into the same post array and I then deal with the data in that array on a separate page. All is working fine with Text Fields, Text Areas and List Boxes however, I am struggling to find how I can get RadioGroup values into my array.

My PHP is:

if (isset($_POST['submit'])) {
	$allvals		=	$_POST['myarray'];
}

...and each form element has its name set to 'myarray' as such:

<textarea name="myarray" cols="40" rows="5"></textarea>
<input name="myarray" type="text" value="">

But due to the way RadioGroups are grouped, i.e. the name of the elements are as follows:

<input type="radio" name="[B]RadioGroup1[/B]" value="1" />
<input type="radio" name="[B]RadioGroup1[/B]" value="2" />

<input type="radio" name="[B]RadioGroup2[/B]" value="1" />
<input type="radio" name="[B]RadioGroup2[/B]" value="2" />

How can I pass the chosen values from these RadioGroups into my $allvals array?

Is it even possible?

Bearing in mind, at the time of displaying the page in the browser, the RadioGroups are dynamically built so there might be one or more groups.

I hope I have made sense and someone can advise.

Many Thanks

    Name them RadioGroup[1], RadioGroup[2], etc. Then the $POST array will contain an array $POST['RadioGroup'], where $_POST['RadioGroup'][1] will contain the value of radio group 1, etc.

      Write a Reply...