agodil
asked on
setting a default value for a form field in asp
<%If Not rsCountries.eof then%>
<select class=content name="COUNTRY" tabindex="14" size="1">
<%If Request.form("country") <> "" Then Do While not rsCountries.Eof
If ucase(Request.form("countr y")) = ucase(rsCountries("COUNTRY _NAME")) Then%>
<option value="<%=rsCountries("COU NTRY_NAME" )%>" selected><%=rsCountries("C OUNTRY_NAM E")%></opt ion>
<%Else%>
<option value="<%=rsCountries("COU NTRY_NAME" )%>"><%=rs Countries( "COUNTRY_N AME")%></o ption>
<%End If
rsCountries.MoveNext
Loop
Else
Do While not rsCountries.Eof%>
<option value="<%=rsCountries("COU NTRY_NAME" )%>"><%=rs Countries( "COUNTRY_N AME")%></o ption>
<%rsCountries.MoveNextLoop
End If%>
</select>
<%End If%>
</td>
</tr>
<tr>
Please help !
<select class=content name="COUNTRY" tabindex="14" size="1">
<%If Request.form("country") <> "" Then Do While not rsCountries.Eof
If ucase(Request.form("countr
<option value="<%=rsCountries("COU
<%Else%>
<option value="<%=rsCountries("COU
<%End If
rsCountries.MoveNext
Loop
Else
Do While not rsCountries.Eof%>
<option value="<%=rsCountries("COU
<%rsCountries.MoveNextLoop
End If%>
</select>
<%End If%>
</td>
</tr>
<tr>
Please help !
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hey mlpk_tyr, i tried the code you wrote but i does not work ! i get an internal server error! should i post the whole code so you can take a look at it ??
Is this still a problem for you? Here's some basic code that should work for setting the value of a select box in ASP (I have taken your code and modified it a bit):
<%
If Not rsCountries.eof then
%>
<select class=content name="COUNTRY" tabindex="14" size="1">
<%
Do While not rsCountries.Eof
If ucase(Request.form("countr y")) = ucase(rsCountries("COUNTRY _NAME")) Then
sSelected = " selected"
else
sSelected = ""
end if
%>
<option value="<%=rsCountries("COU NTRY_NAME" )%>" <%=sSelected%>>
<%=rsCountries("COUNTRY_NA ME")%>
</option>
<%
rsCountries.MoveNext
Loop
%>
</select>
<%End If%>
</td>
</tr>
Let me know if this works for you, or if you have any questions.
Regards,
peh803
<%
If Not rsCountries.eof then
%>
<select class=content name="COUNTRY" tabindex="14" size="1">
<%
Do While not rsCountries.Eof
If ucase(Request.form("countr
sSelected = " selected"
else
sSelected = ""
end if
%>
<option value="<%=rsCountries("COU
<%=rsCountries("COUNTRY_NA
</option>
<%
rsCountries.MoveNext
Loop
%>
</select>
<%End If%>
</td>
</tr>
Let me know if this works for you, or if you have any questions.
Regards,
peh803
https://www.experts-exchange.com/questions/21122318/setting-a-default-value-for-a-form-field-in-asp.html