[FX.php List] Adding a Radio Button set to an Array

William Downs william.downs at gmail.com
Thu Aug 30 08:43:26 MDT 2007


Hi Dale,

thanks for the speedy reply !

I was unsure where to insert your code -
here is my current foreach statement :

<?php
		foreach($salesListResult['data'] as $key=>$salesListData) {	
		$salesrecid = $salesListData['recid'][0];
 		$esNameSales = htmlentities( $salesListData['Name'][0] );
?>
	<li>
		<form id="SalesAssign_<?php echo $salesrecid ?>"
action="SalesAssign.php" method="post">
			<input type="hidden" name="recid" value="<?php echo $salesrecid; ?>">
			<input type="hidden" name="search" value="<?php echo $search; ?>">
                       <p><?php echo $esNameSales; ?>
			<input type="image" name="submit" src="<?php echo $img;?>"></p>		
		</form>
	</li>
<?php
		}
?>

It is the submit I want to swap out with a radio.

Is this clearer ?

William

On 8/30/07, Dale Bengston <dbengston at preservationstudio.com> wrote:
> Hi William,
>
> By nature, radio buttons only allow one to be selected. For multiple
> selections, checkboxes are appropriate. So you need to walk your
> array and create an input for each option in your array, and give
> each input the same name. Assuming a simple array...
>
> $esNameSales = array(12345 => 'Klaus Beaudelaire', 23456 =>
> 'Josephine Antwhistle', 34567 => 'Montgomery Montgomery');
>
> ...then this PHP code...
>
> foreach ($esNameSales as $key => $value)
>         {
>         echo '<input type="radio" name="submit" value="' . $value . '">' .
> $value . '<br>';
>         }
>
> ...would produce this html...
>
> <input type="radio" name="submit" value="Klaus Beaudelaire">Klaus
> Beaudelaire
> <input type="radio" name="submit" value="Josephine
> Antwhistle">Josephine Antwhistle
> <input type="radio" name="submit" value="Montgomery
> Montgomery">Montgomery Montgomery
>
> If your array is more complex, you might have to dig deeper to get
> the values out.
>
> I hope this helps,
> Dale
>
>
> On Aug 30, 2007, at 6:15 AM, William Downs wrote:
>
> > Hi guys,
> >
> > I need to add a radio button set to an array - the array is a returned
> > set from an FX query (name, ID etc) - only the name is displayed to
> > the user
> >
> > Of course, I would want to be able to select ONLY one radio.
> >
> > Just adding "<input type="radio" name="submit" value="<?php echo
> > $esNameSales;?>">" does not make this a set where only one value is
> > selectable
> >
> > I though of merging 2 arrays, but that seems overly complicated -
> > anyone got an idea ?
> >
> > Much thanks in advance
> >
> > William
> >
> > --
> > William Downs
> > Development and Support
> > BD Databases Ltd
> > _______________________________________________
> > FX.php_List mailing list
> > FX.php_List at mail.iviking.org
> > http://www.iviking.org/mailman/listinfo/fx.php_list
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>


-- 
William Downs
Development and Support
BD Databases Ltd


More information about the FX.php_List mailing list