Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 29th, 2005, 05:02 AM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default Retain values in controls.

Which is the best method to program a form which has some database validations e.g. employee id should be unique, and after validationg empid the form should retain other values.
In my case form dosen't retains other values entered in form.

Rupen Anjaria.
We CAN'T avoid problems, but of course can solve it.
 
Old August 6th, 2005, 10:03 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Rupen!!,
For this u need to user

<input type=text name=username value='<%=request("username")%>'>

and form must be post back to itself,




Cheers :)

vinod
 
Old August 6th, 2005, 09:47 PM
Registered User
 
Join Date: Apr 2005
Posts: 352
Thanks: 14
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rupen
Default

Hi Vinod,

If that form posts back to itself, then where to put DB validation?

I will be thank full if you can give me idea of a complete form, viz. Adding new record, modification to them, checking from db.

Rupen Anjaria.
We CAN'T avoid problems, but can solve it.
 
Old August 7th, 2005, 11:41 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Rupen !!
 sure i will try to explain it

suppose that u have a login form (say login.asp ),when user enters the form details(like first name,last name,age,location,password,username).It check whether username is already created by different user<-this requires database check.
If the userName is already exists then you want to give alert for username already exists.
this time you dont want to lost all the details of (name,age,location)

*******login.asp page**********
<script>
     var jsVariable; //this hold whether the form is alerady posted or not
  jsVariable=0;
function callCheck()
{
if(jsVariable==1)
 {
  alert("UserName is already Existed");
   //if you want to clear the usrname text box value then uncomment below line
    // document.myform.username.value=" ";

     document.myform.username.select();
      document.myform.username.focus();
 }
}
</script>
<% if request("isposted")="1" then
     //database checkup for userid already exists ,here is ur sql stmt,recordset check on dB part
      //if dB part is success then set value of databasecheckup="success"

    if(databasecheckup=="success") then
     //store the username in session
     //move to the next page ,which is basicall after the userid has been created
     //you can use server.transfer, response.redirect as per your requirement
     end if

  end if%>


<body onload="callCheck()">
<form name="myform" action="login.asp" method=post>
UserName<input type="text" name="username" value='<%=request("username")%>' > <br>
FirstName<input type="text" name="firstname" value='<%=request("firstname")%>' > <br>
LastName<input type="text" name="lastname" value='<%=request("lastname")%>' > <br>
Address<input type="text" name="address" value='<%=request("address")%>' > <br>
<input type=hidden name="isposted" value="1">
</form>

<%
if reqest("isposted")="1" and databasecheckup<>"success" then
     %>
<script>
   jsVariable=1;
</script>

   <%
end if
%>

</body>

hope this will help you .

Cheers :)

vinod





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retain values of dynamic controls when page fozia_izhar .NET Framework 1.x 1 February 7th, 2007 02:32 PM
Retain the value of Controls S_Dogra ASP.NET 1.0 and 1.1 Professional 1 January 31st, 2007 01:21 PM
How to retain form values from dependent list ? George B Javascript 0 September 15th, 2006 03:54 PM
SOS Retain values on SubmitText field and DropDown rabbit124 Classic ASP Basics 17 March 7th, 2006 07:15 PM
Retain form values qhong Javascript 1 May 13th, 2004 02:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.