Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Preview (and Edit) before Submit -- just one ASP page


Message #1 by "Susan Kent" <susan_kent9@y...> on Sun, 6 Oct 2002 09:32:14
Hello. 
I've been trying to create the above so that users can preview and edit 
their data entry before sending it to the database.  I'm using Select 
Case statements (New record, Preview [and then Edit] record, View 
database records, Confirmation message] so that I can keep all the form 
sections on one ASP page. 
PROBLEM: Whatever the user types transfers to the preview section(using 
hidden fields), but if the user wants to edit what they typed by going 
back to the original section, the data disappears. I don't understand 
why, since I am only using one page. Can someone please explain where I'm 
going wrong in the code? Should I be using hidden fields to send the data 
back to the original section?  And if so, how do I get the New record 
section to pick up these hidden field, given that it is the originating 
section???  Why does everything have to be soooo difficult!
Thanks in advance, if you can help. 
Susan

Simplified code: 
========================= 
<html> 
<head></head> 
<body> 
<form action="messageboard_tester_5oct.asp" method="post" name="formnew" 
id="formnew"> 
  <% 
dim strMode 
strMode = trim(Request.Form("Mode")) 
%> 
  <% Select Case strMode 

Case "", "New"%> 
  <p>section 1 - add a new record</p> 
  <p>name: <input type="text" name="textfield"></p> 
  <p>address:<input type="text" name="textfield2"></p> 
  <p>email:<input type="text" name="textfield3"></p> 
  <p>tel:<input type="text" name="textfield4"></p> 


    <input name="Submit" type="submit" value="Submit"  
onClick="form.Mode.value='Confirm'; form.submit()"> 
    <input name="Reset" type="submit" id="Reset" value="Reset"> 
    <input name="Preview" type="submit" id="Preview4"  value="Preview" 
onClick="form.Mode.value='Preview'; form.submit()"> 
     

    <input name="Dbase" type="submit" id="Dbase3"  value="View Database" 
onClick="form.Mode.value='Existing'; form.submit()"> 
  <hr> 

<% Case "Existing" %> 
    section 2 - existing dbase records </p> 
    <select><option selected>Current records in the 
database:</option></select> 
    <input name="Another" type="submit" id="Another" value="Log another?" 
onClick="form.Mode.value='New'; form.submit()"> 
     

  <hr> 

<% Case "Confirm" %> 
    section 3 confirmation message</p> 
  <p> Thank you. Your entry has been recorded in the database.</p> 
    <input name="Another2" type="submit"  id="Another2" value="Log 
another?" onClick="form.Mode.value='New'; form.submit()">                 
    <input name="Dbase2" type="submit" id="Dbase2"  value="View Database" 
onClick="form.Mode.value='Existing'; form.submit()"> 
  <hr> 
<% Case "Preview" %> 
  <p>section 4 preview</p> 
  <p>You typed the following:</p> 
  <p>name: <%=Trim(Request.Form("textfield"))%> 

    address: <%=Trim(Request.Form("textfield2"))%> 

    email: <%=Trim(Request.Form("textfield3"))%> 

    tel: <%=Trim(Request.Form("textfield4"))%></p> 
  <p> 
    <input name="Edit" type="submit" id="Edit" value="Edit record" 
onClick="form.Mode.value='New'; form.submit()"> 
    <input name="Submit2" type="submit" id="Submit" value="Submit" 
onClick="form.Mode.value='Confirm'; form.submit()"> 
  </p> 
  <hr> 

<% End Select %> 
    <input name="Mode" type="hidden" value=""> 
  </form> 
           
<% Response.end %> 
</body> 
</html>
Message #2 by "John Eix" <jeix@s...> on Sun, 6 Oct 2002 10:16:24 -0400
Hi Susan

The way I did this was to first save the inputted data in a database
(this could be a storage only database i.e. not used for business
purposes), then I showed them the data in a new page and asked them to
confirm or revise, if they chose revision then the form page came up but
now the data inputted was read out of the database so it appeared in the
form fields after they make the changes they click on update and the
database record is updated and stored in the "business database"
similarly if they confirm the data is now saved in the "business
database". More complicated than the one page but it works well. If you
want I can send you the pages, my e-mail address is below. TTYS John

......................................... 
John Eix ]8-) 
E-mail: jeix@s... 
ECS web site: http://eix.dyndns.org/
The Twin's web site http://eix.dyndns.org/twins/
Holly's web site http://eix.dyndns.org/holly/
ChemEd Trading Post: http://eix.dyndns.org/tp/
Hamilton-Niagara Conference: http://eix.dyndns.org/hnc/
Mobile Phone:  xxx-xxx-xxxx  
Phone:  xxx-xxx-xxxx
Eix Consulting Services
1345 Kensington Pk Rd 
OAKVILLE, ON 
L6H 2G8 


-----Original Message-----
From: Susan Kent [mailto:susan_kent9@y...] 
Sent: October 6, 2002 09:32
To: ASP Web HowTo
Subject: [asp_web_howto] Preview (and Edit) before Submit -- just one
ASP page


Hello. 
I've been trying to create the above so that users can preview and edit 
their data entry before sending it to the database.  I'm using Select 
Case statements (New record, Preview [and then Edit] record, View 
database records, Confirmation message] so that I can keep all the form 
sections on one ASP page. 
PROBLEM: Whatever the user types transfers to the preview section(using 
hidden fields), but if the user wants to edit what they typed by going 
back to the original section, the data disappears. I don't understand 
why, since I am only using one page. Can someone please explain where
I'm 
going wrong in the code? Should I be using hidden fields to send the
data 
back to the original section?  And if so, how do I get the New record 
section to pick up these hidden field, given that it is the originating 
section???  Why does everything have to be soooo difficult! Thanks in
advance, if you can help. 
Susan

Simplified code: 
========================= 
<html> 
<head></head> 
<body> 
<form action="messageboard_tester_5oct.asp" method="post" name="formnew"

id="formnew"> 
  <% 
dim strMode 
strMode = trim(Request.Form("Mode")) 
%> 
  <% Select Case strMode 

Case "", "New"%> 
  <p>section 1 - add a new record</p> 
  <p>name: <input type="text" name="textfield"></p> 
  <p>address:<input type="text" name="textfield2"></p> 
  <p>email:<input type="text" name="textfield3"></p> 
  <p>tel:<input type="text" name="textfield4"></p> 


    <input name="Submit" type="submit" value="Submit"  
onClick="form.Mode.value='Confirm'; form.submit()"> 
    <input name="Reset" type="submit" id="Reset" value="Reset"> 
    <input name="Preview" type="submit" id="Preview4"  value="Preview" 
onClick="form.Mode.value='Preview'; form.submit()"> 
     

    <input name="Dbase" type="submit" id="Dbase3"  value="View Database"

onClick="form.Mode.value='Existing'; form.submit()"> 
  <hr> 

<% Case "Existing" %> 
    section 2 - existing dbase records </p> 
    <select><option selected>Current records in the 
database:</option></select> 
    <input name="Another" type="submit" id="Another" value="Log
another?" 
onClick="form.Mode.value='New'; form.submit()"> 
     

  <hr> 

<% Case "Confirm" %> 
    section 3 confirmation message</p> 
  <p> Thank you. Your entry has been recorded in the database.</p> 
    <input name="Another2" type="submit"  id="Another2" value="Log 
another?" onClick="form.Mode.value='New'; form.submit()">

    <input name="Dbase2" type="submit" id="Dbase2"  value="View
Database" 
onClick="form.Mode.value='Existing'; form.submit()"> 
  <hr> 
<% Case "Preview" %> 
  <p>section 4 preview</p> 
  <p>You typed the following:</p> 
  <p>name: <%=Trim(Request.Form("textfield"))%> 

    address: <%=Trim(Request.Form("textfield2"))%> 

    email: <%=Trim(Request.Form("textfield3"))%> 

    tel: <%=Trim(Request.Form("textfield4"))%></p> 
  <p> 
    <input name="Edit" type="submit" id="Edit" value="Edit record" 
onClick="form.Mode.value='New'; form.submit()"> 
    <input name="Submit2" type="submit" id="Submit" value="Submit" 
onClick="form.Mode.value='Confirm'; form.submit()"> 
  </p> 
  <hr> 

<% End Select %> 
    <input name="Mode" type="hidden" value=""> 
  </form> 
           
<% Response.end %> 
</body> 
</html>

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20

Message #3 by "scott frank" <scott@w...> on Tue, 8 Oct 2002 04:34:59
I had the same problem.  The data isn't disappearing, its just not being 
requested when you send the user back.  I use session variables to store 
the information rather then sending them back through the browser as 
hidden variables. Also, I find using Subs make life a little easier for me 
when I've got a lot of action on one page.  You could also use IsEmpty to 
see if the form is blank or has data and direct the user via Subs.

> Hello. 
I> 've been trying to create the above so that users can preview and edit 
t> heir data entry before sending it to the database.  I'm using Select 
C> ase statements (New record, Preview [and then Edit] record, View 
d> atabase records, Confirmation message] so that I can keep all the form 
s> ections on one ASP page. 
P> ROBLEM: Whatever the user types transfers to the preview section(using 
h> idden fields), but if the user wants to edit what they typed by going 
b> ack to the original section, the data disappears. I don't understand 
w> hy, since I am only using one page. Can someone please explain where 
I'm 
g> oing wrong in the code? Should I be using hidden fields to send the 
data 
b> ack to the original section?  And if so, how do I get the New record 
s> ection to pick up these hidden field, given that it is the originating 
s> ection???  Why does everything have to be soooo difficult!
T> hanks in advance, if you can help. 
S> usan

> Simplified code: 
=> ======================== 
<> html> 
<> head></head> 
<> body> 
<> form action="messageboard_tester_5oct.asp" method="post" name="formnew" 
i> d="formnew"> 
 >  <% 
d> im strMode 
s> trMode = trim(Request.Form("Mode")) 
%> > 
 >  <% Select Case strMode 

> Case "", "New"%> 
 >  <p>section 1 - add a new record</p> 
 >  <p>name: <input type="text" name="textfield"></p> 
 >  <p>address:<input type="text" name="textfield2"></p> 
 >  <p>email:<input type="text" name="textfield3"></p> 
 >  <p>tel:<input type="text" name="textfield4"></p> 

> 
 >    <input name="Submit" type="submit" value="Submit"  
o> nClick="form.Mode.value='Confirm'; form.submit()"> 
 >    <input name="Reset" type="submit" id="Reset" value="Reset"> 
 >    <input name="Preview" type="submit" id="Preview4"  value="Preview" 
o> nClick="form.Mode.value='Preview'; form.submit()"> 
 >     

>     <input name="Dbase" type="submit" id="Dbase3"  value="View Database" 
o> nClick="form.Mode.value='Existing'; form.submit()"> 
 >  <hr> 

> <% Case "Existing" %> 
 >    section 2 - existing dbase records </p> 
 >    <select><option selected>Current records in the 
d> atabase:</option></select> 
 >    <input name="Another" type="submit" id="Another" value="Log 
another?" 
o> nClick="form.Mode.value='New'; form.submit()"> 
 >     

>   <hr> 

> <% Case "Confirm" %> 
 >    section 3 confirmation message</p> 
 >  <p> Thank you. Your entry has been recorded in the database.</p> 
 >    <input name="Another2" type="submit"  id="Another2" value="Log 
a> nother?" onClick="form.Mode.value='New'; form.submit
()">                 
 >    <input name="Dbase2" type="submit" id="Dbase2"  value="View 
Database" 
o> nClick="form.Mode.value='Existing'; form.submit()"> 
 >  <hr> 
<> % Case "Preview" %> 
 >  <p>section 4 preview</p> 
 >  <p>You typed the following:</p> 
 >  <p>name: <%=Trim(Request.Form("textfield"))%> 

>     address: <%=Trim(Request.Form("textfield2"))%> 

>     email: <%=Trim(Request.Form("textfield3"))%> 

>     tel: <%=Trim(Request.Form("textfield4"))%></p> 
 >  <p> 
 >    <input name="Edit" type="submit" id="Edit" value="Edit record" 
o> nClick="form.Mode.value='New'; form.submit()"> 
 >    <input name="Submit2" type="submit" id="Submit" value="Submit" 
o> nClick="form.Mode.value='Confirm'; form.submit()"> 
 >  </p> 
 >  <hr> 

> <% End Select %> 
 >    <input name="Mode" type="hidden" value=""> 
 >  </form> 
 >           
<> % Response.end %> 
<> /body> 
<> /html>

  Return to Index