Solved

ASP form calculation

Posted on 2009-07-02
24
923 Views
Last Modified: 2012-05-07
Hey Experts!!   I hope everyone is having a great holiday weekend.  

I have an intranet built on an Access 2003 database and classic ASP.  I have been recently been asked to bulid a budgeting system.  It consists of something like this:
The accessory table contains the pricing, while the other tables contain the client information as well as the product.  The client can have more than one product.  However, each product's pricing is set inside the table.  So one client could have like 3 products with 3 different accessories.  I need to be able to do a budget for up to the next 3 years for one client.  
Bottom Line: 1 Client has 3 products with 3 different accessories.  I need to do a budget for up to the next 3 years with all 3 products(no pricing) with all 3 accessories per prodcut.

I need to be able to have a form, filled out by the user for quantity and then multiplied by the price to give a total.  

I hope I've explained that correctly.  I just have NO idea where to start.  Nor do I know how to do ASP calculations.
0
Comment
Question by:LZ1
  • 12
  • 11
24 Comments
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
LZ1,

This won't just be a basic answer if you want all of that.  Also to provide info on queries you would use we need details on the fields in each table and any relationships between the tables.  If that is all you are really asking for help with then please provide those details.  However if you also need the form page made and the report page then will you be doing the main work yourself and just need help with specific issues?  Or is this a project you need all done for you?  If the latter then it will be best done by hiring a developer in my opinion.  If you do just need help with a specific thing and are working on this yourself then please clarify what you need here.

It does sound like an interesting project.  Let me know if you have any questions or need more information.

b0lsc0tt
0
 
LVL 1

Expert Comment

by:krisrajz
Comment Utility
You may simply use AJAX to do the calculation without submitting the form

Try searching for AJAX with google

Good luck

Regards
Raj
0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
I can provide info and details on AJAX if that is needed but you don't need it if you already planned to submit the form.  Please clarify exactly what you need but researching AJAX could be a distraction if I read your question correctly.  There are lots of ways to caculate and work with forms and database tables without needing AJAX.
bol
0
 
LVL 30

Author Comment

by:LZ1
Comment Utility
@ b0lsc0tt:
I do apologize for my rambling and complexity of the question.  I was looking into AJAX but only found one tutorial(http://www.mikesdotnetting.com/Article.aspx?ArticleID=98) so far on it.  
Ultimately, what will happen is the user chooses a client, from there they will go to the budget.  From there, they choose quantities (and possibly a discount option) and the number of years.  Then boom, it gives them an outlook for the next x amount of years.  
Is that a little more understandable?  I hope so.  :)
0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
Thanks for the response.  I do understand what the project entails.  I am just not sure exactly what you are asking for here.  Keep in mind what I said about project in my first response.  What code do you have?  What step in this project do you need help with now and in this question?
As far as AJAX goes when the users chooses the client they go to a budget, right?  That is on a new page or do you want the page to stay the same?  THAT is the key to whether you will need AJAX.  From what you said it seems you plan to submit the page when the choose a client and show a new page for what is basically step two.  You don't need AJAX for that.  There are a lot of great sites for AJAX info, including one of my favorites that even uses ASP (Classic) for the server code.  A search of this site's knowledge base for comments by me and words ASP and AJAX should show them to you.  You could even open a new question if you want help using or learning AJAX but it doesn't seem like something you need for this project.
Sorry I haven't been able to be specific with the help yet.  Let me know if you have a question about this or the general info I provided.  If this is something you need all done for you then an EE question won't be the way to get it.
bol
0
 
LVL 30

Author Comment

by:LZ1
Comment Utility
I see what your saying b0lsc0tt.  I see that my question is a little confusion.  I do apologize for the extended and unnecessary wording.  Let's start with this then:
Ultimately, I would like to submit the form because it will ultimately be exported to Excel or PDF.  
So how can I perform calculations in classic ASP?
I think this would be best, but I'm not entirely sure.  Suggestions?
0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
ASP can handle math calculations with the same math functions that are available to vbscript.  There is a good list with simple explanations at http://www.w3schools.com/VBscript/vbscript_ref_functions.asp#math .  From you description it seems adding and multiplication will be what you need and those are done with the + sign or * sign.  E.g.
iNum = 5 +3 ' iNum will be 8
iNum = 5 * 3 ' iNum will be 15
Let me know if you have any other questions about caculating in ASP.  If you need help with a specific calculation or having problems with a specific one then please provide details.
bol
0
 
LVL 30

Author Comment

by:LZ1
Comment Utility
Is this the exact syntax for a calculation?  
 

Dim total, total2
 

total=5+3

total2=5*3 

Open in new window

0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
Yes.
0
 
LVL 30

Author Comment

by:LZ1
Comment Utility
How can I apply variables to the formula????  Say I have form fields named:
  • qty_adult
  • qty_batt
  • qty_ped
I have the formula's, but how to declare all the variables and make it calculate? Can you just show me a basic example??  
0
 
LVL 30

Author Comment

by:LZ1
Comment Utility
Those variables are the ones that the user enters.  I would multiply each of those by the price that I have declared already.
0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
You still aren't being very specific it seems.  Hopefully I have understood you correctly but let me know if it doesn't seem right or give the result you expect.  You will need to be more specific on the calculation you need if that is the case.
The snippet below has the code I believe you need.  It will mutliply the 3 variables by their prices and add the results.  Let me know if you have a question about this or how it works.
bol

qty_adult * 10 + qty_batt * 20 + qty_ped  * 30

' assumes the prices are 10, 20 and 30 respectively

Open in new window

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 30

Author Comment

by:LZ1
Comment Utility
I am sorry for badly worded questions.  I do appreciate EVERYTHING your helping me with.  Let me see if I can explain this now.
I have a form that contains the the named form fields above. These I'm pretty sure are the variables.  What I need to do is pass those(as the user submits the form) into the formula that you gave above.  
I think the proper question here is, how do you pass user declared variables into an ASP calculation?  I have declared the variables.  But I want to be able to have the quantities put into the formula(calculation).  
0
 
LVL 54

Accepted Solution

by:
b0lsc0tt earned 500 total points
Comment Utility
Thanks!  Your ASP code can get the values from the form fields by using either Request.Form("FIELDNAME") or Request.Querystring("FIELDNAME").  You would use Form is the form's action is POST and Querystring if the form's action is GET.  Replace "FORMNAME" with the value used in the field's name attribute (e.g. <input name="FIELDNAME" type="text" />).  Let me know if you have a question about this.  If you need something more specific then please show me the form tag and the html for the fields.
Don't forget to validate the form input.  You put the value in an ASP variable but should then validate it before trying to use it.  In this case since you expect numbers you would check to make sure the input from the form is a number and the type of number you expect.  Just a side note or caution but something you should always do. :)
bol
0
 
LVL 30

Author Comment

by:LZ1
Comment Utility
b0lsc0tt you've been very awesome so far.  Thanks for everything.
I'll have to get the code later this evening when I get to that PC.  I'm off-site right now.  
I read what you wrote and it makes sense now.  I know the page starts out by declaring my variables like the code below.
How can I get the value of a different recordset inside of that formula?  Or should I put this formula inside of the same recordset that pulls all of the data?  

<% 

dim, qty_adult, qty_battery, qty_ped, total
 

total=qty_adult*(recordset1 price)

Open in new window

0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
I am glad that made sense and helped.
The code in the snippet doesn't mention a recordset so I am not sure what you refer to by "different recordset."  The code (or formula) in the snippet just needs to go where you need it.  From your earlier post it seems those "qty_" variables and "total" were meant to have info from the form.  If that will go in to a database table then you might have the formula (or code above) in the recordset code or right before it.  It might even be after.  It all matters on the order of the code and its logic.  There is no way I can be more specific but hopefully this explanation helps you know how to use it.  Just remember the variables only last as long as the script runs and the recordset is something that is opened and closed by the script.  You can't do anything with it before or after it is opened/closed.
bol
0
 
LVL 30

Author Comment

by:LZ1
Comment Utility
Here is the entire page of code:
As you can see starting in line 4 is where I want to declare the script and the formulas.
On line 97 I have another recordset that queries all the info I want/need.  
Can I put those recordset variables (rs_contact) into my script?  Would I have to move my script down the line just after the recordset to achieve this?

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

<%session.timeout=540 'time in minutes %>

<%

Dim total, total2, qty_adult, qty_battery, qty_ped, qty_spare_adult, qty_spare_battery, qty_spare_ped

total="qty_adult"+3

total2=qty_ped*3 

qty_adult=20

%>

<%

' *** Restrict Access To Page: Grant or deny access to this page

MM_authorizedUsers="1"

MM_authFailedURL="/login_failed.asp"

MM_grantAccess=false

If Session("MM_Username") <> "" Then

  If (true Or CStr(Session("MM_UserAuthorization"))="") Or _

         (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then

    MM_grantAccess = true

  End If

End If

If Not MM_grantAccess Then

  MM_qsChar = "?"

  If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"

  MM_referrer = Request.ServerVariables("URL")

  if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()

  MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)

  Response.Redirect(MM_authFailedURL)

End If

%>

<!--#include virtual="/Connections/aed_1.asp" -->

<%

' IIf implementation

Function MM_IIf(condition, ifTrue, ifFalse)

  If condition = "" Then

    MM_IIf = ifFalse

  Else

    MM_IIf = ifTrue

  End If

End Function

%>

<%

If (CStr(Request("MM_update")) = "user_client") Then

  If (Not MM_abortEdit) Then

    ' execute the update

    Dim MM_editCmd2
 

    Set MM_editCmd2 = Server.CreateObject ("ADODB.Command")

    MM_editCmd2.ActiveConnection = MM_aed_1_STRING

    MM_editCmd2.CommandText = "UPDATE Client SET user_main = ? WHERE ACT_no = ?" 

    MM_editCmd2.Prepared = true

    MM_editCmd2.Parameters.Append MM_editCmd2.CreateParameter("param1", 202, 1, 255, Request.Form("user_main")) ' adVarWChar

    MM_editCmd2.Parameters.Append MM_editCmd2.CreateParameter("param2", 5, 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)) ' adDouble

    MM_editCmd2.Execute

    MM_editCmd2.ActiveConnection.Close
 

    ' append the query string to the redirect URL

    Dim MM_editRedirectUrl2

    MM_editRedirectUrl2 = "client_test.asp"

    If (Request.QueryString <> "") Then

      If (InStr(1, MM_editRedirectUrl2, "?", vbTextCompare) = 0) Then

        MM_editRedirectUrl2 = MM_editRedirectUrl2 & "?" & Request.QueryString

      Else

        MM_editRedirectUrl2 = MM_editRedirectUrl2 & "&" & Request.QueryString

      End If

    End If

    Response.Redirect(MM_editRedirectUrl2)

  End If

End If

%>

<%

Dim rsUser__MMColParam

rsUser__MMColParam = "1"

If (Session("MM_username") <> "") Then 

  rsUser__MMColParam = Session("MM_username")

End If

%>

<%

Dim rsUser

Dim rsUser_cmd

Dim rsUser_numRows
 

Set rsUser_cmd = Server.CreateObject ("ADODB.Command")

rsUser_cmd.ActiveConnection = MM_aed_1_STRING

rsUser_cmd.CommandText = "SELECT * FROM login WHERE user_name = ?" 

rsUser_cmd.Prepared = true

rsUser_cmd.Parameters.Append rsUser_cmd.CreateParameter("param1", 200, 1, 255, rsUser__MMColParam) ' adVarChar
 

Set rsUser = rsUser_cmd.Execute

rsUser_numRows = 0

%>

<%

Dim rs_contact__MMColParam

rs_contact__MMColParam = "6005"

If (Request.QueryString("Client.ACT_No")      <> "") Then 

  rs_contact__MMColParam = Request.QueryString("Client.ACT_No")     

End If

%>

<%

Dim rs_contact

Dim rs_contact_cmd

Dim rs_contact_numRows
 

Set rs_contact_cmd = Server.CreateObject ("ADODB.Command")

rs_contact_cmd.ActiveConnection = MM_aed_1_STRING

rs_contact_cmd.CommandText = "SELECT DISTINCT (AED_Master.ACT_no) AS Expr1, Client.ACT_no, * FROM (((Contacts RIGHT JOIN Client ON Contacts.ACT_No=Client.ACT_no)  LEFT JOIN AED_master ON Client.ACT_no=AED_master.ACT_No)    LEFT JOIN Models ON AED_master.Model_ID=Models.Model_ID)  LEFT JOIN Cat_Sub ON Client.CatSub_id = Cat_Sub.CatSub_id WHERE (((Client.ACT_no)=?));" 

rs_contact_cmd.Prepared = true

rs_contact_cmd.Parameters.Append rs_contact_cmd.CreateParameter("param1", 5, 1, -1, rs_contact__MMColParam) ' adDouble
 

Set rs_contact = rs_contact_cmd.Execute

rs_contact_numRows = 0

%>

<%

Dim Repeat1__numRows

Dim Repeat1__index
 

Repeat1__numRows = -1

Repeat1__index = 0

rs_contact_numRows = rs_contact_numRows + Repeat1__numRows

%>

<%

Dim Repeat2__numRows

Dim Repeat2__index
 

Repeat2__numRows = -1

Repeat2__index = 0

rs_notes_numRows = rs_notes_numRows + Repeat2__numRows

%>
 

<%

Dim MM_paramName 

%>

<%

' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
 

Dim MM_keepNone

Dim MM_keepURL

Dim MM_keepForm

Dim MM_keepBoth
 

Dim MM_removeList

Dim MM_item

Dim MM_nextItem
 

' create the list of parameters which should not be maintained

MM_removeList = "&index="

If (MM_paramName <> "") Then

  MM_removeList = MM_removeList & "&" & MM_paramName & "="

End If
 

MM_keepURL=""

MM_keepForm=""

MM_keepBoth=""

MM_keepNone=""
 

' add the URL parameters to the MM_keepURL string

For Each MM_item In Request.QueryString

  MM_nextItem = "&" & MM_item & "="

  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then

    MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))

  End If

Next
 

' add the Form variables to the MM_keepForm string

For Each MM_item In Request.Form

  MM_nextItem = "&" & MM_item & "="

  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then

    MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))

  End If

Next
 

' create the Form + URL string and remove the intial '&' from each of the strings

MM_keepBoth = MM_keepURL & MM_keepForm

If (MM_keepBoth <> "") Then 

  MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)

End If

If (MM_keepURL <> "")  Then

  MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)

End If

If (MM_keepForm <> "") Then

  MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)

End If
 

' a utility function used for adding additional parameters to these strings

Function MM_joinChar(firstItem)

  If (firstItem <> "") Then

    MM_joinChar = "&"

  Else

    MM_joinChar = ""

  End If

End Function

%>

<%session.timeout=540 'time in minutes %>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>HeartAED Intranet Home</title>
 

<script type="text/javascript">

<!--

function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}

function GP_popupConfirmMsg(msg) { //v1.0

  document.MM_returnValue = confirm(msg);

}

//-->

</script>

<link href="/CSS/main.css" rel="stylesheet" type="text/css">

<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
 

<script src="includes/datetimepicker.js" type="text/javascript"></script>
 

<style type="text/css">

<!--

#apDiv4 {

	position:absolute;

	width:auto;

	height:581px;

	z-index:1;

	left: 183px;

	top: 200px;

}

#apDiv3 {

	position:absolute;

	width:595px;

	height:251px;

	z-index:1;

	left: 346px;

	top: auto;

	overflow: scroll;

}

#aeds {

	position:absolute;

	width:350px;

	height:465px;

	z-index:1;

	top: 175px;

	left: 300px;

	overflow: scroll;

	border: 1px solid #990000;

	padding: 5px;

	visibility: visible;

	background-color: #FFFFFF;

}

#notes {

	position:absolute;

	width:auto;

	height:200px;

	z-index:13;

	left: 2px;

	top: 117%;

	overflow: scroll;

	visibility: visible;

}

#notes_hdr {

	position:absolute;

	width:603px;

	height:auto;

	z-index:2;

	left: 183px;

	top: 850px;

}

.style1 {color: #FFFFFF; background-image: url(/Images/bg4.jpg); background-repeat: no-repeat; background-position: center; font-family: Arial;}

#to_do {

	position:absolute;

	width:200px;

	height:115px;

	z-index:3;

	left: 898px;

	top: 240px;

}

-->

</style>
 

</head>
 

<body>

<!--#include file="includes/header.asp" -->

<!--#include file="includes/search_div.asp" -->

<!--#include file="includes/div_menu.asp" -->

<div id="apDiv4">

  <table width="541" height="142" border="0" align="center" cellpadding="0" cellspacing="0" class="shadow">

    <tr>

      <th height="142" bgcolor="#FFFFFF" scope="row"> <table width="632" height="142" border="0" align="center" cellpadding="0" cellspacing="0" class="shadow" RULES=COLS FRAME=BOX>

        

          

        <tr>

          <th height="46" colspan="4" class="head_body" scope="col"><%=(rs_contact.Fields.Item("Client").Value)%>&nbsp;

          Information</th>

    </tr>

          

        <tr>

          <th height="12" colspan="4" bgcolor="#FFFFFF" scope="row"><div align="left" class="login_head">Last edited by:<%=(rs_contact.Fields.Item("user_last").Value)%> on <%=(rs_contact.Fields.Item("user_date").Value)%></div></th>

    </tr>

        <tr class="body_text">

          <th width="241" height="18" bgcolor="#990000" class="head_client" scope="row"><div align="left"><%=(rs_contact.Fields.Item("Address").Value)%>&nbsp;<%=(rs_contact.Fields.Item("Address2").Value)%></div></th>

          <th height="18" bgcolor="#990000" class="head_client" scope="row"><div align="left"><span class="highlight">Functions:</span></div></th>

          <th width="24" colspan="2" rowspan="6" bgcolor="#FFFFFF" class="head_client" scope="row">&nbsp;</th>

    </tr>

        <tr bgcolor="#990000" class="head_client">

          <th height="15" class="body_text_address" scope="row"><p align="left" class="head_client"><%=(rs_contact.Fields.Item("City").Value)%>&nbsp;<%=(rs_contact.Fields.Item("State").Value)%>, <%=(rs_contact.Fields.Item("Zipplus").Value)%></p>      </th>

          <th height="15" class="head_client" scope="row"><div align="left"><a href="client_edit.asp?<%= Server.HTMLEncode(MM_keepNone) & MM_joinChar(MM_keepNone) & "Client.ACT_No=" & rs_contact.Fields.Item("Client.ACT_No").Value %>"><img src="Images/buttons/micro_edit.jpg" width="43" height="15" border="0"></a> <span class="head_client">Client Info</span></div></th>

          </tr>

        <tr bgcolor="#990000" class="head_client">

          <th height="9" class="body_text_address" scope="row"><div align="left" class="head_client"><%=(rs_contact.Fields.Item("County").Value)%> County</div></th>

          <th height="9" class="head_client" scope="row"><div align="left"><a href="aed_add.asp?<%= Server.HTMLEncode(MM_keepNone) & MM_joinChar(MM_keepNone) & "Client.ACT_no=" & rs_contact.Fields.Item("Client.ACT_no").Value %>"><img src="Images/buttons/micro_add_aed.jpg" alt="" border="0"></a> To The Client</div></th>

          </tr>

        <tr bgcolor="#999999" class="head_client">

          <th height="5" bgcolor="#C10000" class="head_client" scope="row"><div align="left">

            <p>PH# <%=(rs_contact.Fields.Item("AREA_Phone").Value)%></p>

            </div></th>

          <th height="5" bgcolor="#C10000" class="head_client" scope="row"><div align="left"></div></th>

        </tr>

        <tr bgcolor="#999999" class="body_text">

          <th height="15" valign="top" bgcolor="#C10000" class="head_client" scope="row"><div align="left">

            <p><%=(rs_contact.Fields.Item("Category").Value)%> - <%=(rs_contact.Fields.Item("Subgroup").Value)%></p>

			</div></th>

          <th height="15" align="left" valign="top" bgcolor="#C10000" class="head_client" scope="row">&nbsp;</th>

        </tr>

      </table>
 

      

  </table>    <tr bgcolor="#999999" class="body_text">

      <th colspan="4" bgcolor="#FFFFFF" class="head_client" scope="row">  </th>      </tr>      </th>      </tr>      <td height="2"></tr>

        <% 

While ((Repeat1__numRows <> 0) AND (NOT rs_contact.EOF)) 

%>

        <table width="541" border="0" align="center" FRAME=BOX RULES=COLS>

          <tr>

            <td width="142" rowspan="4"><div align="center"><a href="aed_edit.asp?<%= Server.HTMLEncode(MM_keepNone) & MM_joinChar(MM_keepNone) & "AED_No=" & rs_contact.Fields.Item("AED_No").Value %>"><img src="<%=(rs_contact.Fields.Item("model_img").Value)%>" alt="" name="aed_model" width="75" height="75" border="0"></a><A HREF="aed_edit.asp?<%= Server.HTMLEncode(MM_keepNone) & MM_joinChar(MM_keepNone) & "AED_No=" & rs_contact.Fields.Item("AED_No").Value %>"><br>

                  <span class="results_serial"><%=(rs_contact.Fields.Item("Serial_Code").Value)%></span></A></div></td>

                <td width="142" class="table_hdr"><div align="right">Description:</div></td>

            <td width="80" class="table_hdr">Qty:</td>

            <td width="159" class="table_hdr">Price:</td>

                </tr>

            <tr>

              <td><div align="right">Adult Pads</div></td>

              <td>

                <label>

                  <div align="center">

                    <input name="qty_adult" type="text" class="results_client_client" id="qty_adult" size="3">

                    </div>

                </label>              </td>

              <td>@ $<%=(rs_contact.Fields.Item("adult_price").Value)%></td>

              </tr>

            <tr>

              <td><div align="right">Battery</div></td>

              <td><div align="center">

                <input name="qty_battery" type="text" class="results_client_client" id="qty_battery" size="3">

              </div></td>

              <td>@ $<%=(rs_contact.Fields.Item("battery_price").Value)%></td>

              </tr>

            <tr>

              <td><div align="right">Ped Pads</div></td>

              <td><div align="center">

                <input name="qty_ped" type="text" class="results_client_client" id="qty_ped" size="3">

              </div></td>

              <td>@ $<%=(rs_contact.Fields.Item("ped_price").Value)%></td>

              </tr>

            <tr>

              <td colspan="4"><div align="right">

              </div></td>

              </tr>

            <tr>

              <td>&nbsp;</td>

              <td><div align="right">Spare Adult Pads</div></td>

              <td><div align="center">

                <input name="qty_spare_adult" type="text" class="results_client_client" id="qty_spare_adult" size="3">

              </div></td>

              <td>@</td>

              </tr>

            <tr>

              <td>&nbsp;</td>

              <td><div align="right">Spare Battery</div></td>

              <td><div align="center">

                <input name="qty_spare_battery" type="text" class="results_client_client" id="qty_spare_battery" size="3">

              </div></td>

              <td>@</td>

              </tr>

            <tr>

              <td></td>

              <td><div align="right">Spare Ped Pads</div></td>

              <td><div align="center">

                <input name="qty_spare_ped" type="text" class="results_client_client" id="qty_spare_ped" size="3">

              </div></td>

              <td>@</td>

              </tr>

            <tr>

              <td>&nbsp;</td>

              <td colspan="3"><hr align="center" width="85%"></td>

            </tr>

            

            <tr>

              <td>&nbsp;</td>

              <td class="results_client"><div align="right">Total:</div></td>

              <td class="results_client"><div align="center">

                <input name="qty_total" type="text" class="results_client_client" id="qty_total" value="<%Response.Write(total)%>" size="6">

              </div></td>

              <td class="results_client">@ 

                <input name="price_total" type="text" class="results_client_client" id="price_total" size="6"></td>

              </tr>

        </table>

          <% 

  Repeat1__index=Repeat1__index+1

  Repeat1__numRows=Repeat1__numRows-1

  rs_contact.MoveNext()

Wend

%>

</div>

</body>

</html>

<%

rsUser.Close()

Set rsUser = Nothing

%>

<%

rs_contact.Close()

Set rs_contact = Nothing

%>

Open in new window

0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
The lines in the snippets seem off from what you mention in the response (e.g. line 97 has nothing but ASP open tags).  With ~400 lines and since it is DW code it is not easy to get a quick idea of all that is going on.
I did see the recordset called rs_contact.  Where in the "script" did you want to use its variables?  You will only be able to use them while they exist so if you need that info earlier in the script then you must create the recordset earlier (or twice).  If you need the code you have in lines 4-7 (the "script") in the snippet above in the rs_contact area (the "recordset") then you just need to make sure the script is not below the recordset.  It could be fine right where it is unless it needs to use info from the recordset.  If that is the case it will need to be in the section after rs_contact is made into a recordset.
Does that make sense?  Let me know if anything isn't clear or you have a question.
bol
p.s.  The lines 4-7, i.e. the "script", needs to have the variable's values set somewhere.  If you still need help on this then please clarify if those values come from the form that is submitted or a recordset.
0
 
LVL 30

Author Comment

by:LZ1
Comment Utility
I would like the "calculator" variables to be inside the rs_contact recordset.  This is so they can interact with the rest of the information in there.  I suppose I would need the user "variables" after everything else in the recordset.  
Does that make sense?  
0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
What parts or where are the "calculator" or "user" variables?  I think "calculator" is the lines that were in 4-7 in the recent snippet but please confirm or clarify.
Have you moved them somewhere to see what result you get?  Did you understand what I meant when I said (a few times I think) the variables have to be defined either before or when you use them?  Did you put your formula in the rs_contact recordset?  What was the result?
bol
0
 
LVL 30

Author Comment

by:LZ1
Comment Utility
The calculator is lines 4-7.  I haven't moved it yet, but what I was thinking was moving into the rs_contact recordset.  I think I would put them at the very beginning of the recordset.  Right??
But how would I call other fields in that same recordset to interact with that formula?
Unfortunately I won't have any code until maybe tomorrow.  
0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
Try what I have already suggested to see how it works and the results you get.  Whether you place it in the loop for the recordset, just above that code, or somewhere else usually depends on the result you want (as I have said above).  If you aren't sure how it works then try one and the results usually make it clear.  If you have a question about using what we have said or its results then let us know and be specific and detailed.
I have no idea what you mean by "other fields" but remember I gave the general information in an earlier comment on how to get form fields.  That comment is at http:#a24795127 .  It has the info you need to get any value from a submitted form.
Let us know if you have any other questions about what we have said to answer your question here.  Remember if other questions come up with this project then it is best to open a new EE question for those.
bol
0
 
LVL 30

Author Comment

by:LZ1
Comment Utility
Ok, did what you said and it works great!!  Only problem now is if the page has multiple instances of a product, the total of the first product will go into the total of all the other products even if there isn't a number in the other fields.  I am going to open another question.
Just wanted to say thanks for teaching me something new!!
0
 
LVL 54

Expert Comment

by:b0lsc0tt
Comment Utility
Your welcome!  I am glad I could help.  If you'd like to feel free to post a comment here with the new question's URL.  I will take a look at it and post if I can help.
bol
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now