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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop form reseting when submited

Status
Not open for further replies.

daveyboi

Programmer
Oct 22, 2002
4
GB
Hi - how could i stop a form from reseting all its values when its action is to the same page?

Code:
<form action=blah.asp>
<select name=x>
<option value=&quot;valueOne&quot;>valueOne
<option value=&quot;valueTwo&quot;>valueTwo
</select>
<input type=submit>
</form>

..that submits fine, but if the user had selected 'valueTwo', it would be back a 'valueOne'. I need all the values to stay as they were when submited.

Cheers
 
When you rebuild the page, you'll need to specifically set the Option.

<%
dim sSelectedValue=request(&quot;name&quot;)
%>

<form action=blah.asp>
<select name=x>
<%

response.write &quot;<option value='valueOne' &quot; & iif(sSelectedValue=&quot;valueOne&quot;,&quot;Selected&quot;,&quot;&quot;) & &quot;>valueOne</option>&quot;
response.write &quot;<option value='valueTwo' &quot; & iif(sSelectedValue=&quot;valueTwo&quot;,&quot;Selected&quot;,&quot;&quot;) & &quot;>valueTwo</option>&quot;
%>
</select>
<input type=submit>
</form>

you'll need to add this function to your asp page

function IIF(psEquation,pValue2,pValue3)
if psEquation then
IIF=pValue2
else
IIF=pValue3
end if
end function
&quot;did you just say Minkey?, yes that's what I said.&quot;

MrGreed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top