Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

adment my basket total when the user clicks on a option?

Posted on 2005-03-07
2
Medium Priority
?
260 Views
Last Modified: 2013-12-24
i want to adment my basket total when the user clicks on a option, how can this be done? i want somesort of drop down box with delivery options, that onced selected updated the basket total.


  <cfset variables.basketTotal = 0>
<cfoutput query="display_basket">
<cfset variables.basketTotal = variables.basketTotal + display_Basket.line_price>
  <table width="420" border="0">
    <tr valign="top">
      <td width="176"><strong>Product:
      </strong> #item#<br> <strong>Code:</strong>  <strong>Ref:</strong> #ref#</td>
      <td width="99"><strong>Price:</strong><br>
        #LSEuroCurrencyFormat(price)#</td>
      <td width="131"> <a href="remove.cfm?ref=#ref#">Remove Item</a></td>
    </tr>
    <tr valign="top" bgcolor="##CCCCCC">
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><strong>Sub Total:</strong> #basketTotal#</td>
    </tr>
  </table>



</cfoutput>
<table width="420" border="0">
  <tr>
    <td width="39">&nbsp;</td>
    <td width="236">&nbsp;</td>
    <td width="131" bgcolor="#CCCCCC"><b>Total:</b> <cfoutput>#basketTotal#</cfoutput></td>
  </tr>
</table>

0
Comment
Question by:pigmentarts
2 Comments
 
LVL 18

Expert Comment

by:Plucka
ID: 13475345
Hi pigmentarts,

You can do something like this.

<script language="javaScript">
    function AutoSelect(JumpUrl) {
        window.location.href = JumpUrl;
    }
</script>

Please select your country to calculate the freight cost:
<select name="Country" size="1" onChange="AutoSelect(this.options[Country.selectedIndex].value)">
    <option value="Order.cfm?Country=" selected>Select</option>
    <option value="Order.cfm?Country=Albania">Albania</option>
    <option value="Order.cfm?Country=Algeria">Algeria</option>
    <option value="Order.cfm?Country=American">American</option>
    <option value="Order.cfm?Country=Andorra">Andorra</option>
</select>

When they select an option, a country in this example, it reloads the Order.cfm page with the country parameter so that you can calculate freight / charges etc, etc.

Regards
Plucka
0
 
LVL 8

Accepted Solution

by:
kyle1830 earned 2000 total points
ID: 13476567
you could try this.  Using plucka's example of countries, if you know the value, then just recalculate a value for the form field with the total price.

<script language="JavaScript">
    function ReCalc(){
    var a = document.Test.aTotalPrice.value;
    var b = document.Test.Country.value;
    var c = (a*1+b*1);
    document.Test.bTotalPrice.value = c;
    };
</script>

<form name="Test">
Original Total <input type="Text" name="aTotalPrice" value="10.00">
<br>
New Total <input type="Text" name="bTotalPrice" value="10.00">
<br>
<select name="Country" size="1" onChange="ReCalc(this.options[Country.selectedIndex].value)">
    <option value="0" selected>Select</option>
    <option value="1">Albania</option>
    <option value="2.50">Algeria</option>
    <option value=".75">American</option>
    <option value="1.50">Andorra</option>
</select>
</form>
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question