Calculate freight to multiple addresses

Last post 11-20-2008 4:23 AM by Lance Zhang - MSFT. 1 replies.

Sort Posts:

  • Calculate freight to multiple addresses

    11-16-2008, 11:38 PM
    • Member
      77 point Member
    • MartinaL
    • Member since 10-30-2006, 2:13 AM
    • Posts 167

    I have the following javascript functions which i have been using on an asp website to calculate freight, and it has only ever allowed for shipping to one address.

    Now customers can choose two ship 4 different items to 4 different addresses so I need to update this to calculate the freight to each location and then add it together, how can i do that.


    this is what is being used now when a user enters a shipping postcode and tabs off the field, it calls onChange="getFreight(this.value)"

    var freightareas = new Array()

     <%
        qry = "FreightList"
        set rsqry = dbConn.execute(qry)
        js_counter = 0
        do until rsqry.eof
        %>freightareas[<% =js_counter %>] = new freightarea(<% =rsqry("PostcodeStart") %>,<% =rsqry("PostcodeEnd") %>,<% =rsqry("FreightCost") %>)<%
        response.write(chr(13) & chr(10))
        rsqry.movenext
        js_counter = js_counter + 1
        loop
     %>

     freightareas.length = <% =js_counter %>

     function freightarea(PostcodeStart,PostcodeEnd,FreightCost) {
      this.PostcodeStart = PostcodeStart
      this.PostcodeEnd = PostcodeEnd
      this.FreightCost = FreightCost
     }

     function getFreight(postcode) {
      for(i=0;i<freightareas.length;i++) {
         if(freightareas[i].PostcodeStart <= postcode && freightareas[i].PostcodeEnd >= postcode) {
          if (parseFloat(document.order.winepurchased_final.value) < 350) {
         document.order.freightcost.value = freightareas[i].FreightCost * document.order.totalquantity.value
         document.order.freightcost_final.value = freightareas[i].FreightCost * document.order.totalquantity.value
         }
        else {
        document.order.freightcost.value = 0
        document.order.freightcost_final.value = 0
        document.order.freefreight.value = " Freight is free over $350";
        }
         }
      }
      calTotal()
     }

  • Re: Calculate freight to multiple addresses

    11-20-2008, 4:23 AM
    Answer

    HI MartinaL

    Based on my understanding, you are working with a ASP web application, right?

    This is an ASP.NET forum, and many forum members might not famililar with ASP, so I would like to suggest you try to post the question on a ASP forum, I think you can get more helpful information there.

    Thanks.

    Lance Zhang
Page 1 of 1 (2 items)