Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > ASP Forms
|
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 September 4th, 2003, 08:31 AM
Registered User
 
Join Date: Sep 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing variables between 2 forms on same page

I have multiple pages based on a template (using Dreamweaver MX). This template is split in two parts (div); a menu area and an info (main) area. Each area contains a form. In the menu area form I have different form elements which determine the content of the info area (e.g. a combo box controlling which page is loaded).

Two of these elements are text fields where the user selects dates (using a JavaScript calender). I need to fill the info area with a table of N rows, where N is the numbers of days between the two dates.

As far as I know, the page has to be submitted to the server with these date, generating "new" page on the server side.

What is the best approach when I want to display result on the same page which submits the dates?

Palsam

 
Old September 5th, 2003, 05:24 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Firstly have the form's action set to the same page as it is on, this is the default if you leaver the attribute blank.
Secondly you will need to check in the first few lines of server-side code if the page is being shown for the first time or is a submiossion. The way to do theis is to use the name of one of the requset variables that you know will not be empty when the form is submitted.
For example, let's say one of the date fields is named "startDate" and the forms method is set to "post", this might be the your opening asp code:
Code:
  Dim sStartDate
  sStartDate = Request.Form("startDate)
  If Len(sStartDate) > 0 Then
    'Form has been submitted, process data and write appropriate message.
  Else
    'Page is being shown for first time. 
   End If
--

Joe
 
Old September 5th, 2003, 08:54 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Quote:
quote:Originally posted by joefawcett
 Firstly have the form's action set to the same page as it is on, this is the default if you leaver the attribute blank.

Be careful with this. When the "action" attribute is blank in a form tag, I.E. defaults to a postback to the same page. Other browsers may not do this. I am pretty sure older netscapes won't do anything without a value in "action". Don't know about others. To be safe when you want a page to post back to itself, do this in the form tag:
Code:
action="<%=Request.ServerVariables("SCRIPT_NAME")%>"
Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple 'passing variables between forms' issue... overture C# 4 October 14th, 2005 02:30 PM
Passing variables between forms arcuza General .NET 1 July 11th, 2005 09:08 AM
Passing Session Variables to the Next Page [email protected] Classic ASP Databases 2 August 1st, 2004 01:59 PM





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