<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%><%
Option Explicit
dim table1Summary, table1Caption, newCaption
dim text_field, text_area, check_box, radio_buttons, list_menu
dim submit, complete, item
table1Caption="Fields marked with <span class=""important"">*</span> are required."
newCaption=""
submit=false
complete=false
if request.form("B1")="Submit" then submit=true
text_field=trim(request.form("text_field"))
text_area=trim(request.form("text_area"))
check_box=request.form("check_box")
radio_buttons=request.form("radio_buttons")
list_menu=request.form("list_menu")
if submit=true then
complete=true
if not len(text_field)>0 then
complete=false
newCaption=newCaption&"<span class=""important"">TextField</span>"
end if
if not len(check_box)>0 then
complete=false
if len(newCaption)>0 then
newCaption=newCaption&" and <span class=""important"">CheckBox</span>"
else
newCaption=newCaption&"<span class=""important"">CheckBox</span>"
end if
end if
if complete=true then
' Here is where you can put in a routine to insert DB records
' or send an email message, or whatever it is you want to do
table1Caption="All Done!"
else
table1Caption=""&newCaption
if instr(newCaption,"and")>0 then
table1Caption=table1Caption&" are required fields."
else
table1Caption=table1Caption&" is a required field."
end if
end if
end if
%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form Exmaple</title>
<style type="text/css">
body{
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
}
#form_container {
background-color:#999999;
border:solid thin;
border-color:#333333;
margin-left:30%;
width:400px;
}
caption {
padding:3px;
font-weight:bold;
font-size:0.9em;
}
th {
background-color:#CCCCCC;
font-size:0.8em;
text-align: left;
text-indent: 5px;
width: 90px;
}
td {
background-color:#FFFFFF;
font-size:0.75em;
text-align: left;
text-indent: 5px;
}
.important {color: #FF0000;}
</style>
</head>
<body>
<div id="form_container">
<table id="table1" width="100%" cellspacing="0" cellpadding="2">
<caption>
<%=table1Caption%>
</caption>
<%if complete=false then ' If the form isn't complete show the form.%>
<!--
Notice here form action= nothing. This will force the page
to POST the input data to itself.
-->
<form action="" method="post">
<tr>
<th scope="row"><span class="important">*</span>TextField</th>
<td><input name="text_field" type="text" value="<%=text_field%>" size="20"></td>
</tr>
<tr>
<th scope="row">TextArea</th>
<td><textarea name="text_area" cols="30" rows="5"><%=text_area%></textarea></td>
</tr>
<tr>
<th scope="row"><span class="important">*</span>CheckBox</th>
<td><input name="check_box" type="checkbox" value="1"<%if instr(check_box,"1")>0 then%><%=" checked"%><%end if%>>
<input name="check_box" type="checkbox" value="2"<%if instr(check_box,"2")>0 then%><%=" checked"%><%end if%>>
<input name="check_box" type="checkbox" value="3"<%if instr(check_box,"3")>0 then%><%=" checked"%><%end if%>>
<input name="check_box" type="checkbox" value="4"<%if instr(check_box,"4")>0 then%><%=" checked"%><%end if%>></td>
</tr>
<tr>
<th scope="row">RadioButtons</th>
<td><input name="radio_buttons" type="radio" value="1"<%if len(radio_buttons)=0 or radio_buttons="1" then%><%=" checked"%><%end if%>>
<input name="radio_buttons" type="radio" value="2"<%if radio_buttons="2" then%><%=" checked"%><%end if%>>
<input name="radio_buttons" type="radio" value="3"<%if radio_buttons="3" then%><%=" checked"%><%end if%>>
<input name="radio_buttons" type="radio" value="foo"<%if radio_buttons="foo" then%><%=" checked"%><%end if%>></td>
</tr>
<tr>
<th scope="row">ListMenu</th>
<td><select name="list_menu">
<option value="0"<%if len(list_menu)=0 or list_menu="0" then%><%=" selected"%><%end if%>></option>
<option value="1"<%if list_menu="1" then%><%=" selected"%><%end if%>>Selection 1</option>
<option value="2"<%if list_menu="2" then%><%=" selected"%><%end if%>>Selection 2</option>
<option value="cow"<%if list_menu="cow" then%><%=" selected"%><%end if%>>Selection 3</option>
</select></td>
</tr>
<tr>
<td colspan="2" style="text-align:center;background-color:#999999;"><input name="B1" type="submit" id="B1" value="Submit"></td>
</tr>
</form>
<%end if%>
<!-- Here I loop thru the form elements just to display what is being posted on each submit -->
<!-- I only use code like this for testing, so good idea to remove for production -->
<%for each item in request.form%>
<tr>
<td colspan="2"><%=item&" = "&request.form(item)%></td>
</tr>
<%next%>
</table>
</div>
</body>
</html>