Forum Moderators: coopster

Message Too Old, No Replies

Check boxes

I hate these things

         

ineedmoney

3:24 pm on Jun 5, 2006 (gmt 0)

10+ Year Member



Hello, I am trying to gather info from checkboxes into a form, and then process that information and show what the visitor selected in a input box I can get the value of the checkboxes in an array, but when I attempt the have the value display in a input box, I only get the last value selected. Can anyone help me out and tell me what I'm Doin wrong?

here is my code:

to get the value of the checkboxes

foreach($_POST['colors'] as $value) {
$f .= $value;
}

my code to display in a input box:

<?echo "<input type=text name=3 value=$value size=24 />\n";?>

If any additional info is needed please just ask
Thanks

coopster

3:35 pm on Jun 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I can get the value of the checkboxes in an array

So you are indeed naming your checkboxes with the brackets? See PHP and HTML [php.net] for more details.

jezra

4:23 pm on Jun 5, 2006 (gmt 0)

10+ Year Member



The should be using the $f variable in your display code
<?
echo "<input type=text name=3 value=$f size=24 />\n";
?>

ineedmoney

4:35 pm on Jun 5, 2006 (gmt 0)

10+ Year Member



ahhh we get to the root of the problem, I am a moron...thankyou very much jezra, its working now,

ineedmoney

4:42 pm on Jun 5, 2006 (gmt 0)

10+ Year Member



Does anyone know how I can get the $f to seperate each selction by commas?

coopster

4:47 pm on Jun 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



$f = implode(', ', $_POST['colors']);