Re: Help with PHP processing form checkboxes needed :-(

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 18, 2009 at 06:51:32PM -0700, chris_payne@xxxxxxxxxxxxxxx wrote:

> Hi everyone,
>
> I'm having a major problem.  I have an order system that allows you to add
> items with a checkbox, that works fine.  If you add an item and go back to
> the product listing the items that are in your cart show up as checked on
> the products listing forms to make it easier to see what you have in your
> cart.
>
> My problem comes here:
>
> I have been asked that if you have items in your cart and people are
> browsing your products, when they see it checked (Because they added it
> earlier) - well, basically they want to be able to uncheck it from there 
> and
> delete it from the database, how the heck can I do this?  When you check a
> box it's easy as it sends it's id but if you don't check one it doesn't 
> send
> any data or am I missing something?

When you say "it sends its id", what do you mean? You're not talking
about the ID attribute of the checkbox tag, are you?

The way I handle something like this is to give the checkbox tag a
"value" attribute. Like:

<input type="checkbox" name="mixer" value="ordered_mixer"
checked="checked"/>

Each page has to be a form if you do this. When you check the form, look
for $_POST['mixer'] == 'ordered_mixer'. If that relation is true, the
user left the box checked. If it's not true, the user unchecked the box.

Don't hold me to this. Do an experiment and see if that doesn't work.
I'm operating from memory, and I could be wrong.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux