multiple forms in one asp page?

C

c676228

Hi everyone,
my colleagues are thinking about have three insurance plans on one asp page:

I simplify the plan as follow:

text box:number of people


plan1 plan2 plan3


dropdown menu1: dropdown menu2: dropdown menu3:
for people choose for people choose for people choose
different coverage different coverage different coverage
limit limit limit

.... ... ...

text box11: price1 text box22: price2 text box33: price3


buy button1 buy button2 buy button3


What they want is: 1)if dropdown menu1 is changed then the price1 will be
automatically updated,
if data in menu2/menu3 is changed, then price2/price3 will be
automatically updated...
if number of people to be insured is changed, all three prices will be
update automatically
The only thing I can think of is using javascript, which I don't like use
that much as I just found
out a while ago that in Mac_PC OS 9 with IE installed on it, javascript
doesn't work at all(firebox with mac_pc OS9 is OK).
is there any better way to implement this client side dynamic function?
Is there any easy way to identify which buy button is clicked in the
following asp page, so I know which data set
I need to pass to the next asp page?
should I put the three plans in one form or multiple forms, I never
programed multiple forms in one asp
page. Any expert opinions or suggestions?
 
S

Steven Cheng[MSFT]

Hello Betty,

As for the page's logic you mentioned, IMO, client-side scripting is the
reasonable solution to do it. As you said that you've met the problem with
script on MAC OS, do you mean the script function incorrectly or script
can not run totally?

Based on my experience, for some certain browser model, there does exists
some difference and compatiblility issue between different browsers. If
what you care about is the script difference between multiple browsers,
there exists some article introducing client browser detecting and execute
script according to browser type:


http://www.quirksmode.org/js/detect.html

http://www.webreference.com/js/column6/


for your another question:

=============
should I put the three plans in one form or multiple forms, I never
programed multiple forms in one asp
==============

I think this depend on your data on the form and how you'll process them.

1. When using multiple forms, we can assign separate page to process the
data of each form when the user submit each form respectively. So this can
help separate different code logic into different ASP processing pages.

2. When we post a web page, the data in html form(which is submitted) will
be carried in the http request. Therefore, if you put all the three forms's
elements into one form, everytime you submit the form, all the form
element's data (no matter useful or not) will be carried in httprequest.
This will impact performance when there is large amount of data.
However, if you use multiple forms, each time one form is submited, the
data input in other forms will not be carried in the httprequest, this can
imrpove network transfer performance when the input data is large.

BTW, if you put all the elements in one single form, you can surely
identify which button(1 or 2 or 3) cause the submit at server-side, you can
just at some client-script to mark an <input type="hidden" /> element at
client-side before form submit and check this field at server-side code.
Actually, this is what ASP.NET page do ,you can also adopt this appraoch in
classic ASP page.

Please feel free to let me know if you have anything unclear or any other
information you wonder.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

c676228

Hi Steven,
Thank you for the reply. You are right, in some way, javascript is a good
solution. but MAC OS 9.0 with IE 5.x, Javascript just doesn't work on it at
all(totally, not incorrectly). But MAC OS 10 with IE, javascript works fine.
I am just not a javascript person and It takes too much effort for testing.
The resouce you provided is good, I will refer it later on.
About multiple forms, You are absolutely write, and I will just pass one of
the forms data when one of the buttons is clicked.
I did use Javascript to identify which button is clicked in one of my old
programs.
Acutally, when one of the buttons is clicked, I reset the form values and
then the values are checked on the server-side to determine which button is
clicked.
But I don't know what you mean by <input type="hidden"/>, can you specify a
little more.
Here is mine version:
in the form I have :
<tr>
<td class="alternate"> </td>
<td class="quote"> <input type="submit" name="CFARPlus" value="Buy
Now" onClick="return CheckInput(this.form, 'Y', 'Y')"> </td>
<td class="options"> <input type="submit" name="CFAR" value="Buy Now"
onClick="return CheckInput(this.form,'Y', 'N')"></td>
<td class="options"> <input type="submit" name="NOCFARPlus" value="Buy
Now" onClick="return CheckInput(this.form, 'N', 'Y')"></td>
<td class="options"> <input type="submit" name="NOCFAR" value="Buy
Now" onClick="return CheckInput(this.form, 'N', 'N')"></td>
</tr>
<script language="javascript">
<!--
function CheckInput(form, CFARFlag, PlusFlag) {
if (CFARFlag=='Y' )
form.Plan.value='CFAR';
else
form.Plan.value='No';

if (PlusFlag=='Y')
form.SelectPlus.value='Yes';
else
form.SelectPlus.value='No';
//alert(form.Plan.value);
//alert(form.SelectPlus.value);
return true;

}

//-->
</script>
 
S

Steven Cheng[MSFT]

Hello Betty,

Glad to hear from you.

Yes, I've mentioned using the html hidden field(<input type="hidden" .../>
) to help detect which form is submit. The detailed steps and logic is as
below:


** in each of the html <form> section, you add a <input type="hidden"
.../> element, and this element's value is assigned the corresponding
form's id or name


** When in the handler page(to which all the forms submit to), you can use
code to check the html hidden field e.g.


<% Response.Write("<br/>formid: " & Request.Form("formid")) %>


Thus, you can detect which form is submit. Here are two sample page(one
contains multi forms, another is the handle page which process the form's
submit data...), you can have a look for reference:

===========multi-form page=================
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
</head>
<body>
<br /><br />form1<br />
<form id="form1" name="form1" action="process.asp" method="post">
<input type="hidden" name="formid" value="form1" />
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" value="submit" />
</form>

<br /><br />form2<br />
<form id="form2" name="form2" action="process.asp" method="post">
<input type="hidden" name="formid" value="form2" />
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" value="submit" />
</form>

<br /><br />form3<br />
<form id="form3" name="form3" action="process.asp" method="post">
<input type="hidden" name="formid" value="form3"/>
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" value="submit" />
</form>
</body>
</html>
============================

===========process.asp==================
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
</head>
<body>
<% Response.Write("<br/>formid: " & Request.Form("formid")) %>
</body>
</html>
=========================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

c676228

Steven,
Thank you so much for your detailed reply. I got what you mean. I hope you
will not be tired of my dunderhead question.
 
S

Steven Cheng[MSFT]

Thanks for your followup Betty,

You are always welcome :)

Have a nice day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top