Click here to Skip to main content
15,922,015 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Dynamic LinkButton Text Pin
James T. Johnson12-Mar-02 9:18
James T. Johnson12-Mar-02 9:18 
GeneralRe: Dynamic LinkButton Text Pin
Paul Watson14-Mar-02 1:02
sitebuilderPaul Watson14-Mar-02 1:02 
GeneralRe: Using a variable from code behind in aspx Pin
James T. Johnson17-Mar-02 21:54
James T. Johnson17-Mar-02 21:54 
GeneralRe: Using a variable from code behind in aspx Pin
Paul Watson17-Mar-02 22:11
sitebuilderPaul Watson17-Mar-02 22:11 
GeneralRe: Dynamic LinkButton Text Pin
Marco Cunha14-Mar-02 1:48
Marco Cunha14-Mar-02 1:48 
GeneralNewbie Help With Cookies and Forms Pin
kashmir999912-Mar-02 3:55
kashmir999912-Mar-02 3:55 
GeneralRe: Newbie Help With Cookies and Forms Pin
Roger Wright12-Mar-02 13:19
professionalRoger Wright12-Mar-02 13:19 
GeneralRe: Newbie Help With Cookies and Forms Pin
Paul Watson14-Mar-02 1:47
sitebuilderPaul Watson14-Mar-02 1:47 
kashmir9999 wrote:
want to have a few fields retain the same data from the previous record. My main question is, should I be doing this with a cookie?

You could do it with a cookie but that probably is not the best way.

Here is how I would do it (and I am assuming you are using ASP, not ASP.NET, if not then just message back and I will show you how in ASP.NET):

HTML
<%@ Language=VBScript %>
<%Option Explicit%>
<%
 Dim strNameFirst, strNameLast, dtmDateOfBirth
 
 strNameFirst = Request.Form("txtNameFirst")
 strNameLast = Request.Form("txtNameLast")
 dtmDateOfBirth = Request.Form("txtDateOfBirth")
 
 '- Now do your database code to save the record, but only if there is something to save
 If Request.QueryString("mode") = "save" Then
  '- save to db
 End If
 
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title></title>
  <link rel="Stylesheet" href="main.css" type="text/css" media="screen" />
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
 </head>
 <body>
  <form name="frmPerson" method="post" action="tet.asp?mode=save">
   <table>
    <tr>
     <td align="right">First Name:</td>
     <td><input type="text" name="txtNameFirst" value="<%=strNameFirst%>" /></td>
    </tr>
    <tr>
     <td align="right">Last Name:</td>
     <td><input type="text" name="txtNameLast" value="<%=strNameLast%>" /></td>
    </tr>
    <tr>
     <td align="right">Date of Birth:</td>
     <td><input type="text" name="txtDateOfBirth" value="" /></td>
    </tr>
    <tr>
     <td align="right" colspan="2"><input type="submit" value="Save & Proceed" /></td>
    </tr>
   </table>
  </form>
 </body>
</html>


So basically when the page loads the first time it tries to retrieve the values of txtNameFirst and txtNameLast from the form POST data. However because this is the first time there is no data, but no worries because no error will be raised.

It then ensures that you don't save any new blanl records to the dB with the If.

Then the HTML and form is returned, if there is a value in the strNameFirst or strNameLast variables then they are shown in the text boxes, if not, then nothing is shown in the text boxes. Once again, no error if blank.

When you submit the form it does this all again but this time with values in the text boxes it can "retain state" and show what was typed in last time.

If you want default values then you can init the variables with a default value.

One nice thing about ASP.NET is that it does this kind of thing automatically! So swap to ASP.NET Big Grin | :-D

Good luck Kashmir9999

regards,
Paul Watson
Bluegrass
Cape Town, South Africa

"The greatest thing you will ever learn is to love, and be loved in return" - Moulin Rouge

Sonork ID: 100.9903 Stormfront
General.NET vs J2EE Pin
David Salter11-Mar-02 22:41
David Salter11-Mar-02 22:41 
GeneralSyntax-highlight and Command-completion in ASP.NET Pin
Mats Karlsson11-Mar-02 6:15
Mats Karlsson11-Mar-02 6:15 
GeneralRe: Syntax-highlight and Command-completion in ASP.NET Pin
11-Mar-02 8:13
suss11-Mar-02 8:13 
GeneralRe: Syntax-highlight and Command-completion in ASP.NET Pin
Mats Karlsson11-Mar-02 21:46
Mats Karlsson11-Mar-02 21:46 
GeneralDataGrid in ASP.NET Pin
Mazdak10-Mar-02 21:36
Mazdak10-Mar-02 21:36 
GeneralRe: DataGrid in ASP.NET Pin
omkamal11-Mar-02 8:22
omkamal11-Mar-02 8:22 
GeneralRe: DataGrid in ASP.NET Pin
Mazdak11-Mar-02 8:44
Mazdak11-Mar-02 8:44 
GeneralRe: DataGrid in ASP.NET (possible to inheret DataGrid?) Pin
Paul Watson14-Mar-02 2:11
sitebuilderPaul Watson14-Mar-02 2:11 
GeneralRe: DataGrid in ASP.NET (possible to inheret DataGrid?) Pin
Mazdak14-Mar-02 4:04
Mazdak14-Mar-02 4:04 
Generalchanging cursor using javascript for NN4.x Pin
10-Mar-02 18:55
suss10-Mar-02 18:55 
GeneralRe: changing cursor using javascript for NN4.x Pin
Jeremy Falcon13-Mar-02 3:37
professionalJeremy Falcon13-Mar-02 3:37 
GeneralRe: changing cursor using javascript for NN4.x Pin
Nick Parker14-Mar-02 6:51
protectorNick Parker14-Mar-02 6:51 
GeneralChanging window title in netscape Pin
10-Mar-02 18:33
suss10-Mar-02 18:33 
GeneralRe: Changing window title in netscape Pin
Torsten Mauz14-Mar-02 14:38
Torsten Mauz14-Mar-02 14:38 
Generalopen/close connection to database Pin
Mazdak8-Mar-02 4:26
Mazdak8-Mar-02 4:26 
GeneralRe: open/close connection to database Pin
Nick Parker8-Mar-02 6:08
protectorNick Parker8-Mar-02 6:08 
GeneralRe: open/close connection to database Pin
Mazdak8-Mar-02 7:04
Mazdak8-Mar-02 7:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.