Calculations on Confirmation Page

S

Sammich5

I have a very simple Front Page form, that mails the results to my e-mail.
The confirmation page display the user's inputs correctly. Below is the
script for the confirmation field (again, this part works):

Question 1: <!--webbot bot="ConfirmationField" S-Field="Q1" --></p>
<p>Question 2: <!--webbot bot="ConfirmationField" S-Field="Q2" --></p>
<p>Question 3: <!--webbot bot="ConfirmationField" S-Field="Q3" --></p>

In addition to displaying the user's inputs, I would like to display the sum
of three of the inputs on the confirmation page. I'm not certain that
variables are picking up the value from the confirmation field. This is the
script that I'm currently using:

var Q1Data = ParseInt(window.document.Q1.value);
var Q2Data = parseInt(window.document.Q2.value);
var Q3Data = parseInt(window.document.Q3.value);

Var Sec1Total = Q1Data + Q2Data + Q3Data;

Would you be so kind as to:
1) confirm that what I'm trying to do is possible
2) confirm that my "var" statements will or will not work (and how to
correct them)

Thanks
 
S

Sammich5

Yes. I've published the pages and I can't get the values to show on the
confirmation page. Here are some of the things that I've tried:

<script language="JavaScript">
<!-- Hide from other browsers
window.onLoad = DisplayResults
function DisplayResults()
{
var Q1Data = ParseInt(window.document.Q1.value);
var Q2Data = parseInt(window.document.Q2.value);
var Q3Data = parseInt(window.document.Q3.value);

Var Sec1Total = Q1Data + Q2Data + Q3Data;

document.Screen.display.value = Sec1Total
}

//end hide -->
</script>

Also, in the body I've tried:


<FORM NAME="Results">
<INPUT NAME="submit" TYPE=Sec1Total VALUE=test size="20">
</FORM>

as well as:

<script language="javascript">
document.write(Sec1Total)
</script>

Obviously I'm extremely new to this. Any help would be greatly appreciated.
 
S

Sammich5

Correction to one of my attempts below:

<FORM NAME="Results">
<INPUT NAME="submit" TYPE=Text VALUE=Sec1Total size="20">
</FORM>
 
T

Thomas A. Rowe

You would need to calculate any values on the form and then submit the values with the form data via
hidden form fields.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================
 
S

Sammich5

Sorry if I'm being incredibly dense but . . .
When I create the hidden form field, I'm prompted for a value. I want the
value to be calculated not some default value that I put it. How do I get
this hidden field to calculate it?
 
T

Thomas A. Rowe

You would have use JavaScript to calculate the value and then insert it in the hidden form fields at
the time the form is submitted or you will need to use server-side scripting to write a custom form
handler that can do what you want as well as send the form data via email to you.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================
 
P

p c

For what you want to do, the best way is to write your own response page
to the form--instead of using FPSE to process the form
submission--because FP has its limations. The disadvantage is that you
must know how to do it in ASP or the script language supported on the
server.

Here's how to do it in concept using ASP.

A. In the page where the form is (say myform.html)

Create a clean standard HTML form by deleting the stuff that FP inserts
for use by FPSE (located between the form tags)

* Delete anything that looks like a comment tag that starts with <!--webbot
* if you want, you can add form validation for FPSE later after you know
that the form process works OK.

Clean up any form fields to get clean HTML form fields. For, example for
the Q1 field as text input, you end up with

<input type="text" name="Q1">

Then find the form line that looks like this
<form method="POST" action="--WEBBOT-SELF--">
and change it to
<form method="POST" action="myFormResposne.asp">

The form page will submit the form to the page called myFormResponse.asp

Save the page.

B. In your response page, say myFormResposne.asp

You will be using vbscript to grab and procees the results.
add the following somwhere after the body tag (in HTML view)

<%
'grab form values
Dim nQ1, nQ2, nQ3, nQSum
nQ1=trim(request.form("Q1"))
nQ2=trim(request.form("Q2"))
nQ3=trim(reuest.form("Q3"))

'calculate sum
nQSum= nQ1 + nQ2 + nQ3

'Display confirmation results the way you want
Resposne.write "<br>Q1: " & nQ1
Resposne.write "<br>Q2: " & nQ2
Resposne.write "<br>Q4: " & nQ3
Resposne.write "<br>nQSum: " & nQSum

'write code to email the information if desired

'write code to insert the information into a database if desired

%>


...PC
 
S

Sammich5

Thank you both for all of your help. I'm still working through a couple of
glitches, but feel confident I'm on the right path.

Thanks again
 

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

Top