checkbox vs text box

S

Shank

I have a form with multiple records.
My intention is to have the user click a checkbox for each product he wants.
If I use a text box like the following and enter a 1 for each product,
submit, no problem.
The user gets the products he wants.
<input name="qty" type="text" value="0">

However, if I use the following checkbox code, and assuming the user checks
4 products half way down the page, he will get the first 4 products in the
recordset. If he clicks 1 checkbox, he will always get the first product,
not the product he chose.
<input name="qty" type="checkbox" value="1">

Back to basics... what is the fundamental differnce between the text box and
checkbox?
I would think they would tally the products the same way.

thanks!
 
B

Benjamin Niemann

Hello,
I have a form with multiple records.
My intention is to have the user click a checkbox for each product he
wants. If I use a text box like the following and enter a 1 for each
product, submit, no problem.
The user gets the products he wants.
<input name="qty" type="text" value="0">

However, if I use the following checkbox code, and assuming the user
checks 4 products half way down the page, he will get the first 4 products
in the recordset. If he clicks 1 checkbox, he will always get the first
product, not the product he chose.
<input name="qty" type="checkbox" value="1">

Back to basics... what is the fundamental differnce between the text box
and checkbox?
I would think they would tally the products the same way.

Could you please give us an URL to this document. At least I cannot really
make sense out of your descriptions.
 
J

Jukka K. Korpela

Scripsit Shank:
My intention is to have the user click a checkbox for each product he
wants. If I use a text box like the following and enter a 1 for each
product, submit, no problem.
The user gets the products he wants.
<input name="qty" type="text" value="0">

Using a text box might actually be a better option, especially since it
allows the user to order several copies of a product. Whether the text box
should be initialized to "0" or to an empty string is debatable. I'd vote
for the empty string (value="", which is the default), since it makes it
easier to the user to review his order.

Why would you use a checkbox? Admittedly it is faster when using the mouse,
since you can click on the box (if you can - many people suffer from motoric
disabilities that make it difficult to hit such a small box), as opposite to
clicking on a field and pressing "1". On the other hand, people who fill out
a form efficiently, using the keyboard only, using the tab key to move to
the next field, have no essential difference between the two ways.
However, if I use the following checkbox code, and assuming the user
checks 4 products half way down the page, he will get the first 4
products in the recordset. If he clicks 1 checkbox, he will always
get the first product, not the product he chose.
<input name="qty" type="checkbox" value="1">

Most probably you have named the elements wrongly. The checkboxes need to
have unique names. If you post the URL, probably someone will tell what's
wrong there.
Back to basics... what is the fundamental differnce between the text
box and checkbox?

On fundamental difference is that if a checkbox has not been checked, it
does not contribute anything to the form data set. A text box always
contributes at least the string consisting of its name and the equals sign.
 
S

Shank

Jukka K. Korpela said:
Scripsit Shank:


Using a text box might actually be a better option, especially since it
allows the user to order several copies of a product. Whether the text box
should be initialized to "0" or to an empty string is debatable. I'd vote
for the empty string (value="", which is the default), since it makes it
easier to the user to review his order.

Why would you use a checkbox? Admittedly it is faster when using the
mouse, since you can click on the box (if you can - many people suffer
from motoric disabilities that make it difficult to hit such a small box),
as opposite to clicking on a field and pressing "1". On the other hand,
people who fill out a form efficiently, using the keyboard only, using the
tab key to move to the next field, have no essential difference between
the two ways.


Most probably you have named the elements wrongly. The checkboxes need to
have unique names. If you post the URL, probably someone will tell what's
wrong there.


On fundamental difference is that if a checkbox has not been checked, it
does not contribute anything to the form data set. A text box always
contributes at least the string consisting of its name and the equals
sign.
------------------------------------------------------------------------------
I prefer the checkbox because the user can only select one of each item and
it's considerably faster. When I submit the form using checboxes or text
boxes, there's a considerable difference. The text boxes deliver a comma
delimination for each occurance. The checkboxes only offer comma
delimination for each checkbox that is selected. At this point, I'm assuming
that's the difference between the two and it cannot be changed.
thanks
 
D

Dan

Shank said:
I prefer the checkbox because the user can only select one of each item and
it's considerably faster. When I submit the form using checboxes or text
boxes, there's a considerable difference. The text boxes deliver a comma
delimination for each occurance. The checkboxes only offer comma
delimination for each checkbox that is selected. At this point, I'm assuming
that's the difference between the two and it cannot be changed.

Why don't you name the checkboxes with unique codes corresponding to
the products they are for:

<input type="checkbox" name="item001" value="1"> Item #1
<input type="checkbox" name="item002" value="1"> Item #2
etc.

so that you get results like "item002=1" meaning that the customer is
ordering one of item #2. Then you program your back-end script to act
on these field names and values.
 
J

Jukka K. Korpela

Scripsit Shank:

[ A fullquote, always a useful indicator of lack of comprehensive reading. ]
I prefer the checkbox because the user can only select one of each
item and it's considerably faster.

You're wrong on two accounts. The user can easily modify your form and order
3773737 copies of anything. It's never considerably faster, and it's not
always faster at all.
The text
boxes deliver a comma delimination for each occurance.

What on earth are you talking about?
 
A

Andy Dingley

Shank said:
<input name="qty" type="text" value="0">
However, if I use the following checkbox code, and assuming the user checks
4 products half way down the page, he will get the first 4 products in the
recordset. If he clicks 1 checkbox, he will always get the first product,
not the product he chose.

As a total guess, you appear to be re-using the control name "qty" for
each different product. The web server code can't tell them apart and
its fall-back behaviour appears to be to assume that it's the first
products in order.

To know any more we'd have to see all of your code, including the
server-side stuff.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top