How check box values can be accessed in the form processing
Suppose that you were asked to create a way for a large eCommerce web site to
ascertain the interests of its visitors. You might want to know what product lines
customers are interested in. Rather than asking the user to type into a text box
what product lines they are interested in, it would make more sense to use a series
of check boxes to limit the choices to those that makes sense for your business.
check boxes are useful if there is a group of related yes/no type questions that
are not mutually exclusive. That is, there are a number of yes/no types questions,
and the user should be able to answer each question in the affirmative or negative.
the user interests example, you might ask the users to choose what product
lines they are interested in. You then might list several product lines such as
Home Electronics, Major Appliances, and Stereos. It would be nice to have a series
of check boxes next to each product line name, so that the user could check the
product lines that interest them. In this example, wed have three check
boxes, one for each of the three product lines.
boxes are created with the<input> tag. For a check box, you need to set
the TYPE property to TYPE=CHECKBOX. The NAME property is slightly different for
check box. Rather than having a unique NAME for each check box, you can group
check boxes by giving them all the same NAME. In the product line examples, you
would want to give all three check boxes the same NAME. The VALUE property needs
to be unique among check boxes that have the same NAME. The VALUE property is
what the form processing script will receive when referring to check box group.
write some HTML to create a form to query users about their interests in the three
product lines. The code will create three check boxes. When creating a check box,
the <INPUT> tag only creates the check box. You need to use HTML to label
the check box.
<FORM METHOD=POST ACTION=/scripts/somefile. asp>
lines are you Interested in? <BR>
<INPUT TYPE= CHECKBOX NAME= Product
Line VALUE=HOME Electronics>
TYPE= CHECKBOX NAME= Product Line VALUE=Major Appliances>
<INPUT TYPE=CHECKBOX NAME=Product Line VALUE=Stereos>
can create three check boxes. Recall that checkboxes are created using the <INPUT>tag
with TYPE property set to CHECKBOX. IN 5, 8, AND 11 we create our three related
checkboxes, each with the same NAME.
check box in the group of related checkboxes will be uniquely identified in the
form processing script via the INPUT tags VALUE property.Recommended
to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.
: We never rent, trade, or sell my email lists to
We assure that your privacy is respected
.NET Programming Tutorial Homepage