Hi
I got some great server side validation code from here
The form checks if all the fields are completed etc. When user clicks submit and a field is not completed it marks that textbox as "required" and displays the form again. All the other values the user entered correctly are displayed, but the drop downs don't reflect the values. How do I get them to reflect the values. I have tried to do option value = request. querystring etc but this doesn't work. It will be frustrating if the user has completed the entire form minus one text box. They then complete that text box but now they have to re do all the drop downs. Anyone have a solution? Appreciate it. Thanks! Lee
Here's some of the relevant code
<%
Dim bError
Dim bIsSubmitted
bError = false
' IsSubmitted is hidden field in form
If Request.QueryString("IsSubmitted" = "" Then
bIsSubmitted = false
Else
bIsSubmitted = true
End If
Function IsSelected(sFieldname, sOption)
IsSelected = ""
For Each sSelection in Request.QueryString(sFieldname)
If Trim(sSelection) = sOption Then
IsSelected = " selected"
End If
Next
End Function
%>
FORM STARTS HERE
<tr>
<td align="left" width="430">Title</td>
<td align="left" width="5"> </td>
<td align="left">
<select name="Title" class="inputpension">
<option></option>
<option>Mr</option>
<option>Mrs</option>
<option>Miss</option>
<option>Ms</option>
<option>Dr</option>
<%
aOptions = Array()
For each sOption in aOptions
sSelected = IsSelected("Title", sOption) ' Call IsSelected function
Response.Write "<option" & sSelected & ">" & sOption & "</option>"
Next
%>
</select><img src="images/required_image.gif" width="10" height="9" alt="Expat Financial" />
<%
Response.Write RequiredFieldValidation("Title", "required"
%>
</td>
</tr>
I got some great server side validation code from here
The form checks if all the fields are completed etc. When user clicks submit and a field is not completed it marks that textbox as "required" and displays the form again. All the other values the user entered correctly are displayed, but the drop downs don't reflect the values. How do I get them to reflect the values. I have tried to do option value = request. querystring etc but this doesn't work. It will be frustrating if the user has completed the entire form minus one text box. They then complete that text box but now they have to re do all the drop downs. Anyone have a solution? Appreciate it. Thanks! Lee
Here's some of the relevant code
<%
Dim bError
Dim bIsSubmitted
bError = false
' IsSubmitted is hidden field in form
If Request.QueryString("IsSubmitted" = "" Then
bIsSubmitted = false
Else
bIsSubmitted = true
End If
Function IsSelected(sFieldname, sOption)
IsSelected = ""
For Each sSelection in Request.QueryString(sFieldname)
If Trim(sSelection) = sOption Then
IsSelected = " selected"
End If
Next
End Function
%>
FORM STARTS HERE
<tr>
<td align="left" width="430">Title</td>
<td align="left" width="5"> </td>
<td align="left">
<select name="Title" class="inputpension">
<option></option>
<option>Mr</option>
<option>Mrs</option>
<option>Miss</option>
<option>Ms</option>
<option>Dr</option>
<%
aOptions = Array()
For each sOption in aOptions
sSelected = IsSelected("Title", sOption) ' Call IsSelected function
Response.Write "<option" & sSelected & ">" & sOption & "</option>"
Next
%>
</select><img src="images/required_image.gif" width="10" height="9" alt="Expat Financial" />
<%
Response.Write RequiredFieldValidation("Title", "required"
%>
</td>
</tr>