Digital Point Forums
Moneygram

Go Back   Digital Point Forums > Design & Development > Programming > JavaScript
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old May 17th 2005, 3:50 pm
GoldDog GoldDog is offline
Peon
 
Join Date: Apr 2005
Posts: 5
GoldDog is on a distinguished road
New twist on the price calculator...

Now that the price calculator is working smoothly (see previous post - thanks frankm), I've got to throw a wrench in the works. Whereas the last version recalculated price based on one set price and the quantity chosen, this version has different price options.

Previous version (with a few tweaks):
php Code:
function reCalc() {
    si = document.forms.eQty.qty.selectedIndex;
    v = si*#thispic.price#+#thispic.price#;
    document.getElementById('subT').innerHTML = v;
}
(Note that I had to add the price again, because otherwise the calculated price did not pick up the original value. Odd, but it works.)

This is where it gets strange... #thispic.price# is the price for the item specified in the dB query. However, each item can have several variations, which are retrieved from the dB like so (query name="addon"):
php Code:
SELECT *
FROM ProductStyles
WHERE ProductID = #Val(url.ID)#
So the form will look something like this:
php Code:
Please specify type: <select name="type" onchange="reCalc()">
    <option value="#thispic.price#"> #thispic.ProductName#
    <cfoutput query="addon" group="title">
    <option value="#price#"> #title#</cfoutput>
</select>

Please specify quantity: <select name="qty" onchange="reCalc()">
    <cfloop index="i" from="1" to="10" step="1">
    <option> #i#</cfloop>
</select>
(in the 1st menu, ColdFusion loops through the query results. The 2nd still displays only quantity selected.)

The issue here is that I want to recalculate price everytime either menu is changed. If a different price point is selected in the 1st menu, the displayed price ("subT") must be recalculated according to the quantity specified in the 2nd. My thought was to merely change the function to look like this:
php Code:
function reCalc() {
    si = document.forms.eQty.qty.selectedIndex;
    tp = document.forms.eQty.type.selectedIndex;
    v = si*tp+tp;
    document.getElementById('subT').innerHTML = v;
}
Needless to say, it doesn't work (or I wouldn't be writing this). anybody have any ideas?

thanks again
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Love calculator truelysam Buy, Sell or Trade 7 May 14th 2008 3:16 am
100 Directories Submission (lower price!) bluemouse2 Services 22 May 14th 2005 1:05 am
Need help determining the price for a site retSaMbew General Business 5 Mar 22nd 2005 2:56 pm
Amazon.com affiliate program for price search engine saveontexts Amazon 3 Jan 2nd 2005 9:39 pm
What is the price? schlottke Link Development 1 Jul 9th 2004 6:52 am


All times are GMT -8. The time now is 1:31 am.