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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JavaScript for calculation from two database generated drop-down lists.

    I want to perform a "real-time" calculation on two prices contained within two drop-down list selection in some ASP/SQL code for our intranet site.

    Basically, I have two drop-list price lists (A and B), with each price list being stored in a separate SQL database (ID, Description, Price).

    When both price lists have a valid selection, I want to display the price B - A within the form.

    I have got it working by refreshing the form using an "onchange" event, but this is messy and is causing problems elsewhere, I would love to get it working without having to keep refreshing the page, using JavaScript which is not my strongest skill, and not getting very far.

    Any help very welcome.

    The code for one of the drop-list lists is:

    <select name="DesignerPriceList">
    <option value=0></option>
    <% sqlstr = "SELECT ID, Description, Price FROM TxDesignPriceList WHERE Designer=" & DesignerID & " ORDER BY Description"
    rs2.Open sqlstr, conn
    While Not rs2.EOF %>
    <option value=<%=rs2("ID")%><%If int(DesignerPriceList) = rs2("ID") Then%> SELECTED <%End If%>><%=rs2("Description")%> / £<%=rs2("Price")%></option>
    <% rs2.MoveNext
    Wend
    rs2.Close %>
    </select>


    Regards,

    Steve

  • #2
    Regular Coder
    Join Date
    Aug 2005
    Location
    Toronto, ON, Canada
    Posts
    231
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Breaking object persistence?
    I have got it working by refreshing the form using an "onchange" event, but this is messy and is causing problems elsewhere
    xmlHttpRequest
    would love to get it working without having to keep refreshing the page
    data - business logic - presentation
    try not to cross 3-tier rules (separate BL from presentation)
    rm -f /

  • #3
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by rm-f
    Breaking object persistence?


    xmlHttpRequest


    data - business logic - presentation
    try not to cross 3-tier rules (separate BL from presentation)

    and in English?


    Sorry don't understand.

  • #4
    Regular Coder
    Join Date
    Aug 2005
    Location
    Toronto, ON, Canada
    Posts
    231
    Thanks
    0
    Thanked 0 Times in 0 Posts
    data - business logic - presentation
    try not to cross 3-tier rules (separate BL from presentation)
    You should separate Business Logic (BL) layer from Presentation layer. Do not change session and persistent data in the Presentation layer directly, but send an update request to the BL layer. Otherwise you can run very easy into problems (you have described them as "but this is messy and is causing problems elsewhere").

    M$ recommends to see ASP as part of Presentation layer not as BL layer. BL should be encapsulated in components that are used by ASP.

    xmlHttpRequest
    This is answer to the: "get it working without having to keep refreshing the page". By using xmlHttpRequest you can send data back and forth without "refreshing the page".
    rm -f /

  • #5
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by rm-f
    You should separate Business Logic (BL) layer from Presentation layer. Do not change session and persistent data in the Presentation layer directly, but send an update request to the BL layer. Otherwise you can run very easy into problems (you have described them as "but this is messy and is causing problems elsewhere").

    M$ recommends to see ASP as part of Presentation layer not as BL layer. BL should be encapsulated in components that are used by ASP.


    This is answer to the: "get it working without having to keep refreshing the page". By using xmlHttpRequest you can send data back and forth without "refreshing the page".
    Thanks rm-f,

    I have been researching and playing with xmlHttpRequest and have got it working on a similar feature that I wanted (ie. in a form, select a name from a drop-down list, and get their address and phone number automatically displayed). Works like a dream, and I will now be using this "feature" a lot now. Now going to work on my price-list calculation.....

    Thank you again rm-f for introducing me to this cool feature.

    Still must admit that although I understand what you are saying about separate layers, don't have any idea how to implement this in asp/javascript.


  •  

    Posting Permissions

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