Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll

my Blog

Forms - Check Boxes (by John Kauffman & Charles Carroll)

The checkbox object is coded along the same lines as radio buttons, however each checkbox must get its own unique name since the state of "checked" or "not checked" will be passed to ASP for each box. Remember that you can set more than one option to be checked.

   filename=/learn/test/FormCheckBox.asp

<Test Script Below>


<html><head>
<TITLE>FormCheckBox.asp</TITLE>
</head><body bgcolor="#FFFFFF">
<form action="FormCheckBoxRespond.asp" method="post">
<p>CheckBox Form Example</p>
<p>How do you want your order confirmed?</p>    
<input TYPE="checkbox" NAME="USMail">confirmation sent by first class US Postal Service<br>
<input TYPE="checkbox" NAME="UPS">confirmation sent by UPS overnight letter service<br>
<input TYPE="checkbox" NAME="EMail" CHECKED>confirmation sent by EMail<br>
<input TYPE="checkbox" NAME="Fax">confirmation sent by Fax<br>
<input TYPE="checkbox" NAME="Tel" CHECKED>confirmation made by telephone call<br><br>
<input type="submit"><input type="reset">
</form><hr></body></html>

The responder looks like this:

   filename=/learn/test/FormCheckBoxrespond.asp

<Test Script Below>


<html><head>
<TITLE>formCheckBoxRespond.asp</TITLE>
</head><body bgcolor="#FFFFFF">
<%
If  request.form("USMail")="on" then
   response.write "<br>We will confirm by US Mail"
end if
If  request.form("UPS")="on" then
   response.write "<br>We will confirm by UPS"
end if
If  request.form("EMail")="on" then
   response.write "<br>We will confirm by EMail"
end if
If  request.form("fax")="on" then
   response.write "<br>We will confirm by fax"
end if
If  request.form("tel")="on" then
   response.write "<br>We will confirm by tel"
end if%>
</body>
</html>

There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.