Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Location
    Sumter, SC
    Posts
    178
    Thanks
    10
    Thanked 4 Times in 4 Posts

    Calculating a Total from Dynamic Textboxes??

    I'm having issues with trying to calculate the total value of a dynamic number of text boxes. I've tried using:
    Code:
    <%
       dim qty, bCart
       bCart = Split(Session("CartContents"),"|")
       qty = 0
       dim ship, subtot, gtot
       For i = 0 to UBound(bCart)
    %>	
              qty += cint(document.Order.Quantity(<%'i%>).Value)
    <%	
       Next
       ship = 4.99*(fix(qty/2)+1)
       'subtot = //dunno how to pull a single peice of info from a huge string, need help here as well...
       tgtot = ship+subtot
    but I get an error saying type mismatch in refrence to the qty += line...
    Knowing the total quantity is dire to calculating shipping. How do I manage to cycle through the textboxes created by this code:
    Code:
    <%
       Dim aCart, i, aItems, x, itemcnt
       itemcnt = 0
       aCart = Split(Session("CartContents"),"|")
       For i = 0 to UBound(aCart)
    	Response.Write "<tr>"
    	aItems = Split(aCart(i),"-")
    	For x = 0 to UBound(aItems)
    		Response.Write "<td>" & aItems(x)  & "</td>"
    	Next
    %>
    	<td><input name="Quantity<%=i%>" type="text" size="8" value="1" /></td>
    	</tr>
    <%
       Next
    %>
    and successfully get a total so that I can calculate shipping?

  • #2
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you using ASP Javascript or ASP VBScript?
    Is it Server or Client side?

    It's looks as though you are mixing the two.

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Location
    Sumter, SC
    Posts
    178
    Thanks
    10
    Thanked 4 Times in 4 Posts
    I'd like to stick with vbscript since I've had more experience with it.

    Adding an item to the cart is server side, but the quantity per item is chosen by the user.

  • #4
    Registered User
    Join Date
    Jan 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts
    From all my dealings ASP doesn't recognize +=

    Have you tried changing the += to

    qty = qty + cint(document.Order.Quantity(<%'i%>).Value)

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    Quote Originally Posted by Archangel
    From all my dealings ASP doesn't recognize +=

    Have you tried changing the += to

    qty = qty + cint(document.Order.Quantity(<%'i%>).Value)
    But the document.Order.Quantity(<%'i%>).Value thing looks to me like client side javascript.
    I am the luckiest man in the world

  • #6
    Registered User
    Join Date
    Jan 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts
    But the document.Order.Quantity(<%'i%>).Value thing looks to me like client side javascript.
    You're right...it does, but he's trying to add is using ASP.

    I haven't used arrays in ASP enough to know how to grab the dynamic named boxes, but I'm sure there is a way.

    I can show you how to do it in PHP
    Last edited by Archangel; 03-24-2006 at 08:28 PM.

  • #7
    Regular Coder
    Join Date
    Mar 2006
    Location
    Sumter, SC
    Posts
    178
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Archangel
    You're right...it does, but he's trying to add is using ASP.
    She =)

    I haven't used arrays in ASP enough to know how to grab the dynamic named boxes, but I'm sure there is a way.

    I can show you how to do it in PHP
    I have no clue about php...i'm still getting the hang of asp/vbscript right now and think that would just serve to confuse me more =/ thanks for the offer tho.

    Quote Originally Posted by Roelf
    But the document.Order.Quantity(<%'i%>).Value thing looks to me like client side javascript.
    Its the only thing i've ever used to refrence form items. If its not vbscript then please tell me what I'm supposed to be using. That peice of code came from a friend who uses vbscript/asp for her job.

  • #8
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    See my answer on the other thread. I take it this is the same question. If not then the same principle applies.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •