1 Reply Latest reply on Sep 21, 2008 8:26 AM by Newsgroup_User

    Forms: Unchecked data coming through

    drennan Level 1
      I've setup a form which contains a table of products with checkboxes. I'm new to forms so this may be quite straightforward. At the moment, all products arrive in my inbox (after php script processes the form) and I need only checked items to be sent through. I'm using this in the html doc for each product:

      <td width="30"><input name="ItemA" onClick="change(this)" value="160g" type="checkbox"></td>

      and this in the php script for each item:

      $ItemA = $_POST['ItemA'];
      ------------------------------
      Product A: $ItemA <br>

      So I end up with a long list of products with the weight next to all checked products. It would be great if I could change something so only checked products are sent through.

      Thanks for any help.

        • 1. Re: Forms: Unchecked data coming through
          Level 7
          drennan_uk wrote:
          > $ItemA = $_POST['ItemA'];
          > ------------------------------
          > Product A: $ItemA <br>
          >
          > So I end up with a long list of products with the weight next to all checked
          > products. It would be great if I could change something so only checked
          > products are sent through.

          Use simple conditional logic:

          if (!empty($_POST['ItemA'])) {
          echo 'Product A: ' . $_POST['ItemA'] . '<br>';
          }

          --
          David Powers, Adobe Community Expert
          Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
          Author, "PHP Solutions" (friends of ED)
          http://foundationphp.com/