[thelist] Form validation using ASP

Brian Cummiskey Brian at hondaswap.com
Tue Mar 13 10:25:32 CDT 2007

Kevin Stevens wrote:
> Just for my understanding 
> (and anyone else who comes across this in the future), how does the code
> response.write"selected=""selected"""
> actually work?
What this does is it sets the option value to the selected state, based 
on what is in the session

so if session("foo") = 1 then

 <option value="1" <% if here %>>1</option>
<option value="2" <% if here %>>2</option>

will dynamically write out as:

 <option value="1" selected="selected">1</option>
  <option value="2" >2</option>

When the if statement is inline with the session var check as given in 
the previous posting, thus leaving the correct option pre-selected in 
the list.

> Peter:
> Brian had covered the check box and dropdowns but I was initially still 
> at a loss for the text areas, but your line...
> the content must be placed between the opening and closing tags of the textarea.
> made me figure out how to do it, by changing
> <textarea name="jobdetails" id="jobdetails" rows="7" cols="80" value="<%=Session("jobdetails")%>"></textarea>
> to
> <textarea name="jobdetails" id="jobdetails" rows="7" cols="80"><%=Session("jobdetails")%></textarea>
> and everything worked.
> Thanks again guys, now I've got to catch up on all the time I lost trying to figure it all out :)
At the end of the day, this is basic html.  Using the ASP is just using 
the dynamic side of it to choose which way to print it out.  For 
example, the w3 form builder:

you can see how it is selected there on the left, and displays on the right.

More information about the thelist mailing list