Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Holding the selection of a select box

Status
Not open for further replies.

arundahar

Programmer
Apr 27, 2001
53
GB
When a user chooses a value from my Select box, the page refreshes, how do i hold the value they choose, then make sure that that value is selected within the Select box when the page is refreshed. Is Javascript or using a Session variable the only way?

Thanks

Arun
 
TEST115471.ASP:


<%@ Language=VBScript %>
<%
dim cFruit
cFruit = Request.Form(&quot;fFruit&quot;)

if cFruit <> &quot;&quot; then
Response.Write &quot;Your choice was: &quot; & cFruit & &quot;<br>&quot;
end if
%>

<form method=post action=test115471.asp>
<input type=hidden name=fSubmitted value=yes>
<select name=fFruit onChange=&quot;submit();&quot;>
<option value=apple
<% if cFruit = &quot;apple&quot; then response.write &quot; selected&quot; %>
>Apple<option value=banana
<% if cFruit = &quot;banana&quot; then response.write &quot; selected&quot; %>
>Banana<option value=orange
<% if cFruit = &quot;orange&quot; then response.write &quot; selected&quot; %>
>Orange<option value=peach
<% if cFruit = &quot;peach&quot; then response.write &quot; selected&quot; %>
>peach
</select>
</font>


Maybe you can retrieve your <OPTION>'s from a database, then you can write a small loop...


br
Gerard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top