Page 1 of 1

Checkboxes!!

Posted: Thu Sep 23, 2004 4:27 pm
by AlbinoJellyfish
I have a page with about 10 checkboxes, is there a way i can enter them into an array, then on a later page, separate them so my script can check the prices and then add it together?

If you need more info just ask.

Posted: Thu Sep 23, 2004 4:35 pm
by qads

Code: Select all

<input type="checkbox" name="arrayї]" value="whatever1">
<input type="checkbox" name="arrayї]" value="whatever2">
<input type="checkbox" name="arrayї]" value="whatever3">
<input type="checkbox" name="arrayї]" value="whatever4">
<input type="checkbox" name="arrayї]" value="whatever5">
to process them

Code: Select all

<?php
foreach($_POST['array'] as $key => $value)
{
echo $key." => ".$value."<br />";
}
?>

Posted: Thu Sep 23, 2004 4:49 pm
by AlbinoJellyfish

Code: Select all

<strong>Protocols:</strong>
      <br>
        <input name="array&#1111;]"  type="checkbox" id="r2" value="r2"> 
        R2   
   			&nbsp;&nbsp;&nbsp;
        <input name="array&#1111;]" type="checkbox" id="gr303" value="gr303">
GR-303        
<input name="array&#1111;]"  type="checkbox" id="idsn" value="idsn"> 
IDSN-PRI 
        <input name="array&#1111;]" type="checkbox" id="v5" value="v5">
        V5        
      <br>
    <input name="array&#1111;]" type="checkbox" id="tr08" value="tr08">
    TR08
    <input name="array&#1111;]" type="checkbox" id="calea" value="calea">        
      CALEA          
          <input name="array&#1111;]" type="checkbox" id="ss7" value="ss7">
Like that?

NVM its $_POST

yes but

Posted: Fri Sep 24, 2004 3:02 am
by phpScott
yes that is it but you don't need to use the word array you can use what ever you want as long as it is constant.

I would also name all the ID tags the same with out using the [] like the name tag that way you can use javascript and process the checkboxes as an array if need be.

Posted: Fri Sep 24, 2004 4:11 am
by patrikG
Tutorial Section: viewtopic.php?t=23586