Do not use on any
shared computer
August 30, 2008 12:37am pdt
 
[x]
Attachment Details

Calculating selected dynamic text fields

Tags: Javascript, ASP, Firefox 2, IE7
Hello experts.  I've been running in to some problems generating a sum of specific items that are selected on my site.  There are six columns total  per row(checkbox, part number, description, quantity, list price, and total price).  

I have three sections of the site in which the dynamic field names are slightly different.  The "Total" column has dynamic names consisting of base_total0, base_total1, etc in "Section 1."  The names in "Section 2" are totalA0, totalA1, etc.  And the names in "Section 3" are totalB0, totalB1, etc.  The three sections consist of: Base Model, Standard Items (which all cost $0), and Optional Items.  There are several different Base Models (and prices) that I have to work with, so I am unsure of the total amount of rows and prices that will be used for each, unless I view the code from the website.  There is a different amount for each model.

All of the fields in section 3, except for the checkbox, are disabled on page load.  When a visitor checks a specific item, the rest of the fields become enabled in that row.  I'd like to have another text field at the bottom of the page that calculates the sum of the selected items and neglects the disabled rows/total prices.  There is a "Discount" text box in which the visitor can enter a dollar value.  I'd also like to have another text box below the Discount field that calculates the grand total (Total of selected items - Discount = Grand Total).  The data from the text fields are being sent to another page using Request.form and then exported into Excel.

Note that all of the data is being displayed correctly.  It's being pulled off an AS400 iSeries database.  Below is some of the primary code I'm working with and a screenshot of "Section 3."  Thank you for any help, it's greatly appreciated.  I'm not greatly knowledgeable in this area, so any examples would be most helpful.  Feel free to ask me any questions.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
Base (Section 1)
----------------------------------
Set RS4 = Connection.Execute(BASE)
 
Response.Write("<table>")
 
 rowcounter = 0
 Do While Not RS4.EOF
%>
  
  <form id="form1" name="form1" method="post" action="price_list.asp">
  
<tr id="row">
 
  <td width=25px>
  <input type="checkbox" name="check" value="<%=(RS4.Fields("KPSEQ"))%>" checked disabled onclick="toggle(this.form, 'base_part<%=rowcounter%>', 'base_desc<%=rowcounter%>', 'base_qty<%=rowcounter%>', 'base_price<%=rowcounter%>', 'base_total<%=rowcounter%>', !this.checked)" />  </td>
  
  <td width=80px>
  <input type="text" name="base_part<%=rowcounter%>" value="<%=(RS4.Fields("KPCOM"))%>" size="12" maxlength="14" >  </td>
  
  <td width=500px>
  <input type="text" name="base_desc<%=rowcounter%>" value="<%=server.HTMLEncode("" & RS4("DESCP"))%><%=server.HTMLEncode("" & RS4("DSCPS"))%>" size="82" maxlength="80" >  </td>
  
  <td width=66px>
  <input type="text" name="base_qty<%=rowcounter%>" value="<%=(RS4.Fields("KPQTY"))%>" disabled size="2" maxlength="3" onfocus=this.value="" onchange="this.form['base_total<%=rowcounter%>'].value=(this.value/1) * (this.form['base_price<%=rowcounter%>'].value/1);" >  </td>
 
  <td width=66px>
  <input type="text" name="base_price<%=rowcounter%>" value="<%=(RS4.Fields("LSTPC"))%>" size="8" maxlength="7"  />  </td>
  
  <td width=66px>
  <input type=text name="base_total<%=rowcounter%>" value="<%=(RS4.Fields("LSTPC"))%>" size="5" maxlength="7" >  </td>
</tr>
   
   <%
   rs4.MoveNext
   loop
   rs4.Close
 
 
Standard Items (Section 2)
----------------------------------
<%
Response.Write("<table>")
 
 rowcounter = 0
 Do While Not RS3.EOF
%>
  
  <form id="form1" name="form1" method="post" action="price_list.asp">
  
<tr id="row">
  
<%rowcounter = rowcounter +1%>
 
  <td width=25px>
  <input type="checkbox" name="checkA" value="<%=(RS3.Fields("KPSEQ"))%>" checked onclick="toggle(this.form, 'partA<%=rowcounter%>', 'descA<%=rowcounter%>', 'qtyA<%=rowcounter%>', 'priceA<%=rowcounter%>', 'totalA<%=rowcounter%>', !this.checked)" />  </td>
  
  <td width=80px>
  <input type="text" name="partA<%=rowcounter%>" value="<%=(RS3.Fields("KPCOM"))%>" size="12" maxlength="14" >  </td>
  
  <td width=500px>
  <input type="text" name="descA<%=rowcounter%>" value="<%=server.HTMLEncode("" & RS3("DESCP"))%><%=server.HTMLEncode("" & RS3("DSCPS"))%>" size="82" maxlength="80" >  </td>
  
  <td width=66px>
  <input type="text" name="qtyA<%=rowcounter%>" value="<%=(RS3.Fields("KPQTY"))%>" size="2" maxlength="3" onfocus=this.value="" onchange="this.form['totalA<%=rowcounter%>'].value=(this.value/1) * (this.form['priceA<%=rowcounter%>'].value/1);" >  </td>
 
  <td width=66px>
  <input type="text" name="priceA<%=rowcounter%>" value="<%=fixPrice(RS3.Fields("LSTPC"))%>" size="8" maxlength="7"   />  </td>
  
  <td width=66px>
  <input type=text name="totalA<%=rowcounter%>" value="<%=fixPrice(RS3.Fields("LSTPC"))%>"  size="5" maxlength="7" >  </td>
 
 
</tr>
   
   <%
   rs3.MoveNext
   loop
   rs3.Close
 
 
Optional Items (Section 3)
----------------------------------
<% Response.Write("<table>")
 rowcounter = 0
 Do While Not RS.EOF %>
 
<tr id="row">
  
<%rowcounter = rowcounter +1%>
 
  <td width=25px>
  <input type="checkbox" name="checkB" value="<%=(RS.Fields("KPSEQ"))%>" unchecked onclick="toggle(this.form, 'partB<%=rowcounter%>', 'descB<%=rowcounter%>', 'qtyB<%=rowcounter%>', 'priceB<%=rowcounter%>', 'totalB<%=rowcounter%>', !this.checked)" />  </td>
  
  <td width=80px>
  <input type="text" name="partB<%=rowcounter%>" value="<%=(RS.Fields("KPCOM"))%>" size="12" maxlength="14" disabled>  </td>
  
  <td width=500px>
  <input type="text" name="descB<%=rowcounter%>" value="<%=server.HTMLEncode("" & RS("DESCP"))%><%=server.HTMLEncode("" & RS("DSCPS"))%>" size="82" maxlength="80" disabled>  </td>
  
  <td width=66px>
  <input type="text" name="qtyB<%=rowcounter%>" value="<%=(RS.Fields("KPQTY"))%>" size="2" maxlength="3" onfocus=this.value="" onchange="this.form['totalB<%=rowcounter%>'].value=(this.value/1) * (this.form['priceB<%=rowcounter%>'].value/1);" disabled>  </td>
 
  <td width=66px>
  <input type="text" name="priceB<%=rowcounter%>" value="<%=fixSTD(RS.Fields("LSTPC"))%>" size="8" maxlength="7"  disabled />  </td>
  
  <td width=66px>
  <input type=text name="totalB<%=rowcounter%>" value="<%=fixSTD(RS.Fields("LSTPC"))%>"  size="5" maxlength="7" disabled>  </td>
</tr>
   
   <%
   rs.MoveNext
   loop 
   rs.Close
Attachments:
 
Section 3 Shot
Section 3 Shot
 
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Programming
Question Asked By: hx3
Solution Provided By: ftaco96
Participating Experts: 1
Solution Grade: A
Views: 38
Translate:
Loading Advertisement...
 
[+][-]Accepted Solution by ftaco96

Rank: Master

Accepted Solution by ftaco96:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by hx3
Author Comment by hx3:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by ftaco96

Rank: Master

Expert Comment by ftaco96:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by hx3
Author Comment by hx3:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by ftaco96

Rank: Master

Expert Comment by ftaco96:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by ftaco96

Rank: Master

Expert Comment by ftaco96:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by hx3
Author Comment by hx3:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by hx3
Author Comment by hx3:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by hx3
Author Comment by hx3:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by ftaco96

Rank: Master

Expert Comment by ftaco96:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by hx3
Author Comment by hx3:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by hx3
Author Comment by hx3:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by hx3
Author Comment by hx3:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by ftaco96

Rank: Master

Expert Comment by ftaco96:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628