|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi I am using a cart script called Cre Loaded.
Inside the cart there is a file that defines the "quntity box" for "sub-products" of one master product. In my case, the master is an album. the subs are MP3 songs. I do not need quantity box. I would like to replace it with a check box. So that: unchecked means = quanitity 0 Checked means quantity 1 here is the original code: code / <td class="productListing-data"><?php echo TEXT_ENTER_QUANTITY;?> : <?php echo tep_draw_input_field('sub_products_qty[]', '0','size="5"') . tep_draw_hidden_field('sub_products_id[]', $sub_products['products_id']);;?></td> /code if I replace the "tep_draw_input_field" to "checkbox field" and add ($checked = false,) within the (), I get the box. But how do I get it to add 1 when checked. Thanks for your . |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Wed, 13 Feb 2008 06:47:08 +0100, a-c-h <info@plasmarecords.com> wrote:
> Hi I am using a cart script called Cre Loaded. > Inside the cart there is a file that defines the "quntity box" for > "sub-products" of one master product. > In my case, the master is an album. > the subs are MP3 songs. I do not need quantity box. I would like to > replace it with a check box. > So that: > unchecked means = quanitity 0 > Checked means quantity 1 > > here is the original code: > code / > <td class="productListing-data"><?php echo TEXT_ENTER_QUANTITY;?> : > <?php echo tep_draw_input_field('sub_products_qty[]', > '0','size="5"') . tep_draw_hidden_field('sub_products_id[]', > $sub_products['products_id']);;?></td> > /code > > if I replace the "tep_draw_input_field" to "checkbox field" and add > ($checked = false,) within the (), I get the box. > But how do I get it to add 1 when checked. > Thanks for your . I have no idea how your code works, however, give your checkbox the value of 1 by default: it won't be there on post if unchecked, so depending on the code it will throw an exception or error, or interpret it as 0, on a check, the value is as '1' as if someone entered '1' in a text field. -- Rik Wasmus |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Hi Rik
I tried this: <td class="productListing-data"><?php echo TEXT_ENTER_QUANTITY;?> : <?php echo tep_draw_checkbox_field('sub_products_qty[]', '1','size="5"') . tep_draw_hidden_field('sub_products_id[]', $sub_products['products_id']);;?></td> In the list of products, it doesn't work properly. Is there a way first to define <input type> and then add the code? Please only pay attention to this part: <?php echo tep_draw_checkbox_field('sub_products_qty[]', '1','size="5"') Thanks |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Wed, 13 Feb 2008 19:48:48 +0100, a-c-h <info@plasmarecords.com> wrote:
> Hi Rik > > I tried this: > <td class="productListing-data"><?php echo TEXT_ENTER_QUANTITY;?> : > <?php echo > tep_draw_checkbox_field('sub_products_qty[]', > '1','size="5"') . tep_draw_hidden_field('sub_products_id[]', > $sub_products['products_id']);;?></td> > > In the list of products, it doesn't work properly. 'does not work properly' is not an error description I can do anything with. > Is there a way first to define <input type> and then add the code? > Please only pay attention to this part: <?php echo > tep_draw_checkbox_field('sub_products_qty[]', > '1','size="5"') tep_draw_checkbox_field() is not a PHP function, so you'll have to ask the people who made Cre Loaded. Myself, I'd just have the field in raw HTML instead of using a function. -- Rik Wasmus |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Sorry about the confusing message. Here is a better explanation:
in the file named "/product_info.tpl.php" I changed: PHP: echo tep_draw_input_field('sub_products_qty[]', '0', 'size="5"') . tep_draw_hidden_field('sub_products_id[]', $sub_products['products_id']); To: PHP: echo tep_draw_checkbox_field('sub_products_qty[]', 1) . tep_draw_hidden_field('sub_products_id[]', $sub_products['products_id']); the code works but this happens: suppose there are 8 subproducts, 1. click 1 checkbox (any) = only 1st product get added 2. Click any 2 checkboxes = first 2 products get added 3. check any 3 = only first three products get added So if I check only the 8th box, the 1st product gets added instead. I think the problem is, when a checkbox is not checked, it doesn't send anything. It somehow need to send the quantity value "0". Could we add a hidden field to send 0 value for unchecked products? Or, is there a way to define checked=1 uncheked=0 Thanks |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
a-c-h wrote:
> Sorry about the confusing message. Here is a better explanation: > > in the file named "/product_info.tpl.php" I changed: > PHP: > echo tep_draw_input_field('sub_products_qty[]', '0', 'size="5"') . > tep_draw_hidden_field('sub_products_id[]', > $sub_products['products_id']); > > To: > PHP: > echo tep_draw_checkbox_field('sub_products_qty[]', 1) . > tep_draw_hidden_field('sub_products_id[]', > $sub_products['products_id']); > > the code works but this happens: > > suppose there are 8 subproducts, > > 1. click 1 checkbox (any) = only 1st product get added > 2. Click any 2 checkboxes = first 2 products get added > 3. check any 3 = only first three products get added > > So if I check only the 8th box, the 1st product gets added instead. > I think the problem is, when a checkbox is not checked, it doesn't > send anything. It somehow need to send the quantity value "0". Could > we add a hidden field to send 0 value for unchecked products? Or, is > there a way to define > checked=1 > uncheked=0 > Thanks > > > You should have your checkbox "name=" attribute set to a value which can be related to the product at hand. That way you can check to see if the $_POST['checkbox_name_here'] value is set, and if so, increment the related quantity. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Feb 13, 9:08pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> a-c-h wrote: > > Sorry about the confusing message. Here is a better explanation: > > > in the file named "/product_info.tpl.php" I changed: > > PHP: > > echo tep_draw_input_field('sub_products_qty[]', '0', 'size="5"') . > > tep_draw_hidden_field('sub_products_id[]', > > $sub_products['products_id']); > > > To: > > PHP: > > echo tep_draw_checkbox_field('sub_products_qty[]', 1) . > > tep_draw_hidden_field('sub_products_id[]', > > $sub_products['products_id']); > > > the code works but this happens: > > > suppose there are 8 subproducts, > > > 1. click 1 checkbox (any) = only 1st product get added > > 2. Click any 2 checkboxes = first 2 products get added > > 3. check any 3 = only first three products get added > > > So if I check only the 8th box, the 1st product gets added instead. > > I think the problem is, when a checkbox is not checked, it doesn't > > send anything. It somehow need to send the quantity value "0". Could > > we add a hidden field to send 0 value for unchecked products? Or, is > > there a way to define > > checked=1 > > uncheked=0 > > Thanks > > You should have your checkbox "name=" attribute set to a value which can > be related to the product at hand. That way you can check to see if the > $_POST['checkbox_name_here'] value is set, and if so, increment the > related quantity. > > -- > ================== > Remove the "x" from my email address > Jerry Stuckle > JDS Computer Training Corp. > jstuck...@attglobal.net > ==================- Hide quoted text - > > - Show quoted text - Is there anybody who can give me an example code? Which will do the follwoing: Checked box=value 1 unchecked box value=0 The solution to assign value seems right. But i am not good at writing the syntax. Thanks |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
a-c-h wrote:
> On Feb 13, 9:08 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote: >> a-c-h wrote: >>> Sorry about the confusing message. Here is a better explanation: >>> in the file named "/product_info.tpl.php" I changed: >>> PHP: >>> echo tep_draw_input_field('sub_products_qty[]', '0', 'size="5"') . >>> tep_draw_hidden_field('sub_products_id[]', >>> $sub_products['products_id']); >>> To: >>> PHP: >>> echo tep_draw_checkbox_field('sub_products_qty[]', 1) . >>> tep_draw_hidden_field('sub_products_id[]', >>> $sub_products['products_id']); >>> the code works but this happens: >>> suppose there are 8 subproducts, >>> 1. click 1 checkbox (any) = only 1st product get added >>> 2. Click any 2 checkboxes = first 2 products get added >>> 3. check any 3 = only first three products get added >>> So if I check only the 8th box, the 1st product gets added instead. >>> I think the problem is, when a checkbox is not checked, it doesn't >>> send anything. It somehow need to send the quantity value "0". Could >>> we add a hidden field to send 0 value for unchecked products? Or, is >>> there a way to define >>> checked=1 >>> uncheked=0 >>> Thanks >> You should have your checkbox "name=" attribute set to a value which can >> be related to the product at hand. That way you can check to see if the >> $_POST['checkbox_name_here'] value is set, and if so, increment the >> related quantity. >> >> -- >> ================== >> Remove the "x" from my email address >> Jerry Stuckle >> JDS Computer Training Corp. >> jstuck...@attglobal.net >> ==================- Hide quoted text - >> >> - Show quoted text - > > Is there anybody who can give me an example code? > Which will do the follwoing: > Checked box=value 1 > unchecked box value=0 > > The solution to assign value seems right. But i am not good at writing > the syntax. > Thanks > You won't get an unchecked value. HTTP only sends information to the server on checked checkboxes. So you need to know what checkboxes are on your form, then on the next page set the appropriate values as necessary. But I also agree with Rik - you need to be asking the people who created Cre Loaded. We don't know their code, and have no idea how things would interact. Whatever we give you is more likely to cause more problems than to solve them. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
![]() |
| Outils de la discussion | |
|
|