TAKempis Internet Programming Home
Home Uncle Chutney's Journal Information, Tutorials
Sponsored by my good friends of many years, at iLand Internet Solutions
Start Marquee
Stop Marquee

<body>
<div class="linkDiv" id="headerTable">
<table border="0" cellspacing="0" class="linkTable">
<tr>
<td style="text-align:left"><!-- #BeginEditable "TopLinkLeft" -->
<!-- #EndEditable -->&#32;</td>
<td style="text-align:center"><!-- #BeginEditable "TopLinkMiddle" -->
<!-- #EndEditable -->&#32;</td>
<td style="text-align:right"><!-- #BeginEditable "TopLinkRight" -->
<!-- #EndEditable -->&#32;</td>
</tr>
<tr>
<td colspan="3"><a href="../Default.asp"><img src="../images/newtaklogo.gif"
alt="TAKempis Internet Programming Home" /></a>
<div style="margin:5px 0px 5px 0px"><a target="_blank"
href="https://mvp.support.microsoft.com/profile=C4ECE5F0-D7F1-4572-B283-D5104A022187">Microsoft
MVP (Most Valuable Professional)</a></div>
</td>
</tr>
<tr>
<td style="text-align:left">
<a href="../Default.asp">Home</a></td>
<td>
<a target="_blank"
href="http://unclechutney.blogspot.com/">Uncle Chutney's Journal</a></td>
<td style="text-align:right">
<a href="../information.asp">Information, Tutorials</a></td>
</tr>
</table>
</div>
<div class="marquee" id="marquee"><span id="marqueeText">Sponsored by my good friends of many years,
at <a href="http://www.iland.com/">iLand Internet Solutions</a></span>
</div>
<hr style="position:absolute; top:190px;" />
<div id="marqueeStart"><a href="javascript:startMarquee()">Start Marquee</a></div>
<div id="marqueeStop"><a href="javascript:stopMarquee()">Stop Marquee</a></div>
<div class="tocDiv">
<ul style="list-style-image: url('../images/ArrowRightBlue.gif')">
<li><a href="../information.asp">Information, Tutorials,</a><br />
<a href="../information.asp">Trouble-shooting</a></li>
<li><a href="../about.html">Who Am Us, Anyway?</a></li>
<li><a href="../angela.htm">Angela&#39;s Humpback Cloister</a></li>
<li><a target="_blank" href="http://UncleChutney.blogspot.com">Uncle
Chutney&#39;s Journal</a></li>
<li><a target="_blank" href="http://www.miradyne.net">Miradyne.net</a></li>
<li><a target="_blank" href="http://www.iLand.com">iLand
Internet Solutions</a></li>
</ul>
<!-- ********************* Addional TOC Column Content Goes here ********************** -->
<!-- *** TOC is 160PX wide with a 10PX right margin - total 170PX ********************* -->
<!-- #BeginEditable "ListPanel" -->
<p><%if Request.Form("color") = "" then
color = "#808080"
flag = 0
else
color = Request.Form("color")
flag = 1
end if
name = Request.Form("name")
other = Request.Form("other")%></p>
<!-- #EndEditable -->
</div>
<!-- *************************** Body Content Goes here ******************************* -->
<!-- ***Content Div is 854PX wide ***************************************************** -->
<div class="contentDiv">
<!-- #BeginEditable "Body" -->
<h1>An ASP Form Which Submits to Itself</h1>
<%if flag = 0 then%><p>This tutorial will hopefully teach you how to create an ASP
page with a form which submits to itself. This demonstration will use the form below to
gather information, and when that form is posted, will return to this page with the form
populated with the information you've entered, along with an explanation of how it was
done. As you can see, there is no explanation yet. But after you submit the form, it will
&quot;magically&quot; appear below the form, on this same page. Isnt' that exciting? I
can't wait, can you? So, let's get started!</p><%end if%>
<form method="post" action="submit.asp">
<table style="width:100%;border-style:solid;border-width:2px;background-color:<%Response.Write color%>">
<tr>
<td style="font-size:11pt;color:#FFFFFF"><strong>Please enter your Name:</strong></td>
<td><input type="text" name="name" size="20" value="<%Response.Write name%>" /></td>
</tr>
<tr>
<td style="font-size:11pt;color:#FFFFFF"><strong>Please enter some other text:</strong></td>
<td><textarea rows="2" name="other" cols="29"><%Response.Write other%></textarea></td>
</tr>
<tr>
<td style="font-size:11pt;color:#FFFFFF"><strong>Please select a color:</strong></td>
<td><strong><input type="radio" value="#FF0000" checked="checked" name="color" id="fp1" /><label for="fp1">Red</label> <input type="radio" name="color" value="#0000FF" id="fp2"><label for="fp2">Blue</label> <input type="radio" name="color" value="#800080" id="fp3"><label for="fp3">Purple</label></strong></td>
</tr>
<tr>
<td style="font-size:11pt;color:#FFFFFF"><input type="submit" value="Submit to Myself!" name="B1" /></td>
<td><%if flag = 1 then%>
<p><strong>More Details Follow! (See Below)</strong></p><%else%>&nbsp;<%end if%></td>
</tr>
</table>
</form>
<%if flag = 1 then%><p>Hey! Where'd the introductory paragraph go? It's magic!
Actually, here's how it works. First, you have to detect whether the page was reached by
means of typing in the URL or by submitting the form on the page. this is done by placing
a server-side script at the top of the page:</p>
<p>&lt;%<strong>if Request.Form(&quot;color&quot;) = &quot;&quot;</strong>
then<br />
&nbsp;&nbsp;&nbsp;&nbsp; color = &quot;#808080&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp; flag = 0<br />
else<br />
color = Request.Form(&quot;color&quot;)<br />
&nbsp;&nbsp;&nbsp;&nbsp; flag = 1<br />
&nbsp;&nbsp;&nbsp;&nbsp; end if<br />
name = Request.Form(&quot;name&quot;)<br />
other = Request.Form(&quot;other&quot;)%&gt;</p>
<p>The first thing which the script does is look at the <strong>Request
Object</strong>'s <strong>Form Object</strong>'s <strong>Parameters Collection</strong>
(see the bold type above) to see whether there is any value for a parameter named
&quot;color&quot; (the radio button group in the form). If there isn't any value (resolves
to &quot;&quot;), it assigns the value &quot;#808080&quot; to a variable named
&quot;color,&quot; and a value of 0 to a variable named &quot;flag.&quot; Then it looks at
the values of form fields named &quot;name&quot; and &quot;other&quot; and assigns their
values to variables of the same name.</p>
<p>The rest of it is fairly simple. I used the &quot;color&quot;
variable in the table as a background color. Each radio button has the Hex code for that
color as its' value, and the colde for the table background looks like this:</p>
<p>&lt;table border=&quot;1&quot; width=&quot;100%&quot; bgcolor=&quot;<strong>&lt;%Response.Write
color%&gt;</strong>&quot;&gt;</p>
<p>Then I just used the same technique for the default values in
the text boxes, and determined whether to print certain blocks of text based upon the
value of the &quot;flag&quot; variable.</p>
<p>And you thought it was magic! Click the &quot;Reset&quot;
link below to reset the page to its' original configuration. It simply calls the page by
URL, and doesn't submit a form to it.</p>
<p style="text-align:center"><strong><a href="submit.asp">Reset This Page</a>
|<%end if%> <a href="Submitcode.asp">See all the code.</a>
|<%end if%> <a href="Submitcode.asp">See all the code.</a></strong></p>
<!-- #EndEditable -->
<div class="linkDiv" id="footerTable">
<table class="linkTable">
<tr>
<td style="text-align:left"><a href="../Default.asp">Home</a></td>
<td><a target="_blank" href="http://unclechutney.blogspot.com/">Uncle Chutney's Journal</a></td>
<td style="text-align:right"><a href="../information.asp">Information, Tutorials</a></td>
</tr>
<tr>
<td colspan="3"><a href="../Default.asp">
<img src="../images/newtaklogo.gif" alt="TAKempis Internet Programming Home"
style="width: 290px;" /></a></td>
</tr>
<tr>
<td style="text-align:left"><!-- #BeginEditable "BottomLinkLeft" -->
<!-- #EndEditable -->&#32;</td>
<td style="text-align:center"><!-- #BeginEditable "BottomLinkMiddle" -->
<!-- #EndEditable -->&#32;</td>
<td style="text-align:right"><!-- #BeginEditable "BottomLinkRight" -->
<!-- #EndEditable -->&#32;</td>
</tr>
</table>
<div class="linkDiv"><strong>&#169; 1997-2007 by TAKempis - All Rights Reserved</strong></div>
</div>
</div>
</body>

Home Uncle Chutney's Journal Information, Tutorials
TAKempis Internet Programming Home
© 1997-2007 by TAKempis - All Rights Reserved