Need help to complete this code ( checkbox)

Discussion in 'PHP' started by AMJED, Feb 17, 2017.

  1. #1
    Hello

    i need your help to let this code working as I want.
    I want to make group or multiple checkbox values.

    I put it like this :
    echo "<tr class='tab_bg_2'><td>".__('additional Devices')."</td>";
          echo "<td><input type='checkbox' name='dvcs' value='Labtop' > labtop".$resa->fields["dvcs"]." <br>";
          echo "<input type='checkbox' name='dvcs1' value='Projector' > projector ".$resa->fields["dvcs1"]."<br>";
          echo "<input type='checkbox' name='dvcs2' value='Remote'>remote ".$resa->fields["dvcs2"]."<br>";
          echo "</td></tr>\n";
    PHP:
    in the form file , added this :

     $input['dvcs']             = $_POST['dvcs'];
    $input['dvcs1']             = $_POST['dvcs1'];
    input['dvcs2']            = $_POST['dvcs2'];
    PHP:

    and I have added the dvcs, dvcs1, dvcs2 colums in the database, mysql.

    after I check the box, it is showing the check box again longer with what I have checked.
    these pics are showing to you what happens exactly.

    I want it only to show the values I have checked!
    appreciate any help.


    *********
    new form, I now check Projector only. then I will post it.
    chch.PNG
    I have posted it, it show like this ?!

    checked.PNG

    the yellow color is the only I need. the rest inside the blue circle I need it to be
    removed after I checked what I want in the previous step. or at least to show it
    same as I checked projector. without permission to check any more boxes or update.



    waiting your help.
    thanks
     
    AMJED, Feb 17, 2017 IP
  2. SpacePhoenix

    SpacePhoenix Well-Known Member

    Messages:
    197
    Likes Received:
    28
    Best Answers:
    2
    Trophy Points:
    155
    #2
    Don't forget that if a checkbox isn't selected then no value will be sent for that checkbox which will result in undefined index errors
     
    SpacePhoenix, Feb 17, 2017 IP
  3. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    819
    Best Answers:
    7
    Trophy Points:
    320
    #3
    If you ONLY need ONE answer from many, why are you using CHECK BOXES which by definition mean that you want anywhere from ZERO to the MAXIMUM number of check boxes available? Use radio buttons.
     
    mmerlinn, Feb 18, 2017 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    What I want to know is why the form is using a table to format the form's looks... And no label... meh. Horrible code.
     
    PoPSiCLe, Feb 18, 2017 IP