Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    keep the values when it redirect the same page

    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.

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Location
    Brasília, Brazil
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't have Windows now to test it but you can try:
    Code:
    <tr><td>First Name:</td><td>
    <input type="text" name="fname" size="32" value="<% = Request.QueryString("fname") %>" />
    </td></tr>

  • #3
    New to the CF scene
    Join Date
    Apr 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried it.

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

    Thanks.

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you are using several pages then storing the info in Session variables may be best.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •