
February 24th, 2003, 12:44 PM
|
|
Junior Member
|
|
Join Date: Feb 2003
Posts: 15
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
i do the same thing with my forms, where when it redirects back to the form but maintains the values. first i used a querystring; this worked fine, until i started using textareas, which allowed for multiple lines of input. so now i use forms. whatever section the code enters, i have it write out a form with hidden input elements set to the values of the form. then the form submits itself in javascript code when the page loads. on the form end, then, i retrieve the variables. for text fields, it's as simple as putting the variables straight into the inputs, but to have drop down boxes select the appropriate option, it gets tricky. here's what i did for that:
//This function writes "selected" for the matching term when the
//user has entered invalid info, and is redirected back to the form
//to fill in appropriate information
//num is any one of the following
//1 = gender, 2 = birthmonth, 3 = birthday, 4 = state
//option is the value of the option that's being written
function select(num, option) {
var category;
if (num == 1) { category = gender; }
else if (num == 2) { category = birthmonth; }
else if (num == 3) { category = birthday; }
else if (num == 4) { category = state; }
option = new String(option);
category = new String(category);
if(option.valueOf() == category.valueOf()) {
Response.Write(" selected");
}
}
then an example of when the page writes the select input:
<select class="formselect" name="gender">
<option<%select(1, "");%>></option>
<option<%select(1, "Male");%>>Male</option>
<option<%select(1, "Female");%>>Female</option>
</select>
that's my solution anyway... if you want to use session variables to store form info, i'd think that would work , too:
Session("name") = name
Session("PUDeliv") = PUDeliv
you'll still have to do the function call for PUDeliv's select input
|