...

View Full Version : keep the values when it redirect the same page



accessman2
04-15-2006, 06:37 AM
Hi,

I have a question.

I made the create the new user form.

<script language="javascript">

function submitFrm()
{
document.submitform.action="complete.asp"
document.submitform.submit();
}
function Validate()
{
var username = document.submitform.username.value;
var password = document.submitform.password.value;
var email = document.submitform.email.value;
var str = ""

if (username=="")
{str="Username";}
if (password=="")
{str=str + "\nPassword";}
if (email=="")
{str=str + "\nE-Mail";}

if (username=="" || password=="" || email=="")
{ alert("Please Fill out the following field:\n\n" + str);}
else {return submitFrm();}
}
</script>

<form name="submitform" method="post" action="" OnSubmit="Validate()">
<center>
<table border=2>
<tr><td>First Name:</td><td><input type="text" name="fname" size="32" /></td></tr>
<tr><td>Last Name:</td><td><input type="text" name="lname" size="32" /></td></tr>
<tr><td>Sex:</td><td><input type="radio" name="sex" value="Male">Male</input>
<input type="radio" name="sex" value="Female">Female</input></td></tr>
<tr><td>Username:</td><td><input type="text" name="username" size="32" /></td></tr>
<tr><td>Password:</td><td><input type="password" name="password" size="32" /></td></tr>
<tr><td>E-Mail:</td><td><input type="text" name="email" size="32" /></td></tr>
<tr><td></td><td><center><input type="submit" value="Submit" /><input type="reset" value="reset" /></center></td></tr>
</table>
<%
if request.querystring("new")="exists" then
Response.Write("Username already exists in database.")
end if
%>

It works fine, but I want to keep back the Firstname, lastname, sex, and e-mail values. How can I keep the values once it redirect the newuser page.

Because, if there is one invalide value, then it will redirect the same page and remove all values I input.

How can I keep firstname, lastname, sex, and e-mail values?
Thanks.

Kakao
04-15-2006, 12:10 PM
I don't have Windows now to test it but you can try:


<tr><td>First Name:</td><td>
<input type="text" name="fname" size="32" value="<% = Request.QueryString("fname") %>" />
</td></tr>

accessman2
04-15-2006, 07:39 PM
I tried it.

It still give out the empty field when it redirect the same page.
It cannot keep the value.

Thanks.

degsy
04-18-2006, 04:52 PM
If you are using several pages then storing the info in Session variables may be best.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum