PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Newbie need
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Newbie need

Réponse
 
LinkBack Outils de la discussion
Vieux 13/02/2008, 05h47   #1
a-c-h
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Newbie need

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 .
  Réponse avec citation
Vieux 13/02/2008, 08h46   #2
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie need

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
  Réponse avec citation
Vieux 13/02/2008, 18h48   #3
a-c-h
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie need

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



  Réponse avec citation
Vieux 13/02/2008, 19h28   #4
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie need

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
  Réponse avec citation
Vieux 14/02/2008, 03h03   #5
a-c-h
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie need

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


  Réponse avec citation
Vieux 14/02/2008, 05h08   #6
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie need

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
==================

  Réponse avec citation
Vieux 17/02/2008, 00h59   #7
a-c-h
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie need

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
  Réponse avec citation
Vieux 17/02/2008, 02h42   #8
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Newbie need

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
==================

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 18h29.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16524 seconds with 16 queries