C and S Design.
Search Friendly Programming and Design



Get this Code: Click to download the ASP file.
Do not copy and paste the displayed code. The display function adds line breaks so what you see is definitely not what you would get.

Code for this Example. (Maintain Form Values)

<%
' this code goes above the dtd
%>
<%
dim i
dim frmAction
dim select_value
dim text_value
dim frmJS
dim value_array(4)
value_array(1) = "zero"
value_array(2) = "one"
value_array(3) = "two"
value_array(4) = "three"

frmAction = lcase(request.form("submit"))

if frmAction = "" or frmAction = _ 
	"cancel" then
	frmJS = "onFocus=" & chr(34) & _ 
	"this.value="" & chr(34)
	text_value = "Text Input"
	select_value = 0
elseif frmAction = "accept" then
	select_value = request.form("test_select")
	text_value = request.form("test_txt_input")
	frmJS = "onFocus=" & chr(34) & _ 
	"this.select()" & chr(34)
end if
%>


<%
' page code
%>

<div  id="the_form">
<form action="default.asp" _ 
	method="post" name="test_form" >
<h3>The Form; </h3>
<div class="row centre">
<div class="cell">Text Box
</div> <!-- cell -->
<div class="cell">Select Box
</div> <!-- cell -->
</div> <!-- row -->
<div class="row centre">
<div class="cell">
<input type="text" _ 
	name="test_txt_input" _ 
	id="test_txt_input" <%=frmJS%> _ 
	value="<%=text_value%>" />
</div> <!-- cell -->
<div class="cell">
<select name="test_select" _ 
	id="test_select">
<option value="0">Select From</option>
<%
with response
for i = 1 to ubound(value_array)
.write "<option value="
.write chr(34)
.write i
.write chr(34)
if i = cint(select_value) then
.write " selected ="
.write chr(34)
.write "selected"
.write chr(34)
end if
.write ">"
.write value_array(i)
.write "</option>"
next
end with

%>
</select>
</div> <!-- cell -->
</div> <!-- row -->
<div class="row centre">
<div class="cell">
<input type="submit" name="submit" _ 
	id="acc_submit" value="Accept" _ 
	title="Accept the values on the form"/>
</div> <!-- cell -->
<div class="cell">
<input type="submit" name="submit" _ 
	id="can_submit" value="Cancel" _ 
	title="Clear form values back to defaults"/>
</div> <!-- cell -->
</div> <!-- row -->
</form>
</div>



Valid HTML 4.01! Valid CSS! copyright © C and S Design 2004 - 2005
Website Design and SE Friendly Coding C and S Design