# Calculating Shipping With If/else And Function?

Sep 21, 2009

I am having difficulty getting the following assignment to run properly:Many companies charge a shipping and handling charge for purchases. Create a Web page that allows a user to enter a purchase price into a text box and includes a JavaScript function that calculates shipping and handling. Add functionality to the script that adds a minimum shipping and handling charge of \$1.50 for any purchase that is less than or equal to \$25.00.For any orders over \$25.00, add 10% to the total purchase price for shipping and handling,but do not include the \$1.50 minmum shipping and handling charge. The formula for calculating a percentage is price * percent / 100. For example, the formula for calculating 10% of a \$50.00 purchase price is 50 * 10 / 100, which results in a shipping and handling charge of \$5.00. After you determine the total cost of the order (purchase plus shipping and handling), display it in an alert dialog box. Save the document as CalcShipping.html.This is what I have after working on it round and round for 4 hours yesterday:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">[code].....

## Shipping Calculation :: Modify Script To Calculate The Shipping Cost?

Oct 18, 2011

i have follow a tutorial from this site http:[url]....i would like to customize the script for shipping cost as in like: for the drop down , user can choose either 'west' or 'east' on the drop down, my problem now is i don't know how to modified JavaScript to calculate the shipping cost and i have done the calculation for product quantity in php.i would like to do it like using my \$ct_qty(php) *shipping cost (javascript).if user select west:

1 quantity = \$6

2 quantity = \$8

3 quantity = \$9...and so on...8 quantity above = F.O.C

and for east showing different price like:

1 quantity = \$9

2 quantity = \$13

3 quantity = \$15...and so on...8 quantity above = F.O.C

## Simplecart Js Quantity Shipping - Specify Different Shipping For Different Items?

May 14, 2011

I am using simplecart js and I am trying to get shipping to work.

<script type="text/javascript">
simpleCart.email = "payment@domain.co.uk";
simpleCart.checkoutTo = PayPal;[code]....

Now the problem with this is whenever I add any item to the cart it adds �1 to the shipping, but I want to specify different shipping for different items. Is there anyway I can do this?

## Calculating / Populating Function - Percent Variable Showing Up NaN

Jul 1, 2011

I have 2 things going on here. One, the 'percent' variable is constantly showing up as NaN (not a number) no matter what numbers I give it. I suspect it is happening because the function is populating all the fields at one, which causes a 'divide by zero' scenario for the percentage field, which is last in line. Which brings me to my send thing. How to write this function correctly, as it obviously is causing problems as is, and it seems clunky. I think it should broken up into a couple different functions, but I tried that and NOTHING worked.

Here is the code, let me kow what you think:
function calculate(){
var contractsSold = document.forms[0].contractsSold.value;
var priceSold = document.forms[0].priceSold.value;
var totalSold = (contractsSold * priceSold) * 100;
var gainLoss = totalSold - totalAdded;
var percent = gainLoss / totalAdded;

document.forms[0].totalSoldCost.value = totalSold;
document.forms[0].gainLoss.value = gainLoss;
document.forms[0].returnPercent.value = percent;
}

## Calculating Input Fields - Get The Math Function To Calculate And Display Properly

Nov 5, 2009

I can't seem to get the math function to calculate and display properly. Can anyone point me in the right direction.

Here is my code.

## Shipping Calculator

Jan 17, 2006

I'm attempting to create a shopping cart shipping calculator using the total \$ provided by the cart itself (%total%). Basically the script needs to take the %total%, compare it to a bunch of arrays in the javascript, and provide the shipping charge as a percentage of the total. For example:

The cart total ends up being \$15 (or %total%).

The set rates for shipping are:

Standard Shipping
\$1 - \$4.99 : 7.95% (of total)
\$5 - \$9.99 : 9.95%
\$10 - \$19.99 : 11.95%

Overnight Shipping
\$1 - \$4.99 : 9.95% (of total)
\$5 - \$9.99 : 11.95%
\$10 - \$19.99 : 19.95%

Two radio buttons would show the 2 shipping options and the shipping charges like this:
O Standard: \$1.79
O Overnight: \$2.99

## Can't Combine Shipping Across Items?

Dec 2, 2010

Right now this javascript shopping cart works to 1. charge shipping based on the item, 2. the destination country, 3. it combines shipping for a quantity over 1 of the SAME item.Each item has 2 different possible shipping charges. I am trying to get the javascript to check the shopping cart to see what item in the cart has the highest possible shipping charge, charge that amount to that item, and charge the lowest possible shipping charge on all other items in the cart. If item A is purchased alone shipping is \$5.00.If purchased with item B, which costs \$10.00 to ship alone, the \$10.00 is charged for item B and only \$3.00 for item A. Because item B had the higher shipping charge at a quantity of one.

I have tried adding various things like me.items[current], item.shipping, me.shipping, this.shipping, shipping_Cost, and other things next to the second && in the part of the script that shows the country. I have also tried adding && if (me.whatever) and && if (item.whatever) and similar things at the beginning of the script next to if (this.country). I have found the parts of the script that pertain to cart items and to updating the shopping cart.The javascript is in 2 parts. One part goes in the item page, which I will post first. The second part goes in an external javascript file which I will post at the bottom. In between there is the part that shows the shopping cart. It isn't part of the javascript.

<script type="text/javascript" src="simpleCart.js"></script>
<script type="text/javascript">
<!-- [code]......

## Jquery :: Copy Billing/Shipping IE7 OE Error?

May 1, 2011

I have created a form that includes billing and shipping information. When the user clicks the checkbox next to "Shipping Information is the same as Billing Information" the form should copy the contents filled in the shipping fields to the billing fields. All works well, except in Internet Explorer 7, I get an object expected error. I'm using jQuery JavaScript Library v1.4.2.

Code:
<div class="box1 store-customer-info">
<h1>Checkout - Step 2 of 3</h1>
<div class="records">[code]....

## State Field For Copying Shipping Same As Billing Not Working?

Dec 7, 2009

I am trying to copy the billing information to be the same as the shipping information when they select the checkbox. Everything seems to work except for the State field which is a drop down. Depending on what country they select, the state field will automatically populate. how I can copy the billing state to be the same as shipping as well?

## Multiple The Quantity Ordered By The Kind Of Shipping Selected In My <select> List?

Mar 4, 2009

What I want to do it multiple the quantity ordered by the kind of shipping selected in my <select> list.

I'm pretty sure that what I've got to do is establishe a quantity ordered variable like this var qty = form["Q" + i].value And then multiply that qty variable by the ShippingCost. But no mater where I stick this var statement it always either stops the script cold or comes up as a black or undefined value.

<script type="text/javascript">
/* <![CDATA[ */
var ListCount = 5[code].....

## How To Make A Simple Select Menu That Adds A Flat Rate Shipping Fee?

Oct 18, 2005

Can someone tell me how to make a javascript that will add a shipping price (\$5.00) to any price that is listed as a value for a select menu on multiple drop downs?

<select name="shirt">
<option value="10.00">s-l</option>
<option value="12.00">xl-xxl</option>
</select>

Price: <input type="text" name="total" value="\$0.00" /> (would show this without touching the drop down)
Price: <input type="text" name="total" value="\$15.00" /> (would show this if selecting s-l)
Price: <input type="text" name="total" value="\$17.00" /> (would show this if selecting xl-xxl)

<select name="shorts">
<option value="14.00">s-l</option>
<option value="16.00">xxl-xxl</option>
</select>

Price:
<input type="text" name="total" value="\$0.00" /> (would show this without touching the drop down)
Price: <input type="text" name="total" value="\$19.00" /> (would show this if selecting s-l)
Price: <input type="text" name="total" value="\$21.00" /> (would show this if selecting xl-xxl)

Mar 1, 2010

i have a table, with 2 numeric values at the minute, if the checkbox is selected I want the total price to be shown? this is the form I have with the numeric values

<form id="calculation" action="#" method="post">
100 <input type="checkbox" name="check1" value="100" onClick='total_cost()'/>
120 <input type="checkbox" name="check2" value="200" onClick='total_cost()'/>[code].....

## Calculating A Person's Age?

Dec 1, 2010

I am trying to write a script that will take a date of birth and another date and, if the person was over 75 years old on the createdDate, return "true" (otherwise return "false").

Unfortunately my code doesn't seem to return either 'true' or 'false'!

The code is:

var dateofBirth="30/10/1982";
var createdDate="01/12/2010";
var sd = dateofBirth.split('/');
var dob = new Date(sd[2],sd[1],sd[0]);

[Code]....

Jul 23, 2005

I want to create a link that a user can click which will create a popup
telling the user their ip address. I have:

but this does not seem to work. It says the ip is 127.0.0.1. Strangely,
this piece of code used to work but all of a sudden it doesn't for some
unknown reason. Can anyone tell me what's wrong with the above code?

## Calculating Difference Between Two Dates Using JS

Nov 10, 2006

I have two date fields (check in, check out) and "number of days"
field.

I want the script to calculate automatically the difference.
For example: I have defaults dates, and I want the script to put the
difference in "number of days" field. And if the user will change the
date, the number of days will change automatically.

## Calculating Age From Date Of Birth?

Jul 11, 2009

I am using date of birth field in my application and i m taking date of birth in yyyy-mm-dd format.

I need to calculate age by using this date of birth and should show alert if age is less than 5 years.

## Auto Calculating Form

Mar 22, 2007

I've been googleing for a auto calculating form and found nothing, I just want something .. some form, that can add values from different fields ... and make a sum .. in real time ... meaning that ... if I put X value in field #1 and Y value in field #2, at the bottom or somewhere I should have the X+Y value :P..

## Calculating Textbox Value For Html?

Mar 6, 2010

calculating textbox value from java script for html

Example: (textbox1value X textbox2value) + (textbox3value + textbox4value)= result

where result value should display in textbox5

## Calculating Difference Between The Two Numbers?

Jul 2, 2009

the following javascript is not calculating the difference between the two numbers.cant understand y

<script language="JavaScript" type="text/javascript">
function showAmt(){
total = document.total.value;[cod

## Calculating The Average/mean In An Array ?

Mar 30, 2011

Im trying to calculate the mean/average of numbers in an array.how can i get the length of an array to perform in a simple / maths problem whilst being flexiable to the length of the array?

function sum()
{
var i=0 [code].....

## Calculating Percentage In A Form?

Mar 23, 2010

I am writing a form and doing a bunch of calculations one of which is a percentage based on the value selected. I am returning a correct result for two of the values but for the other two I am not.The 'discount' value is what I am looking for. It should return as 0 for values of 1 but it is doing the math as though it is multiplying by 1. And again for the value of 6 it should be 10% but is taking the value as 4.6 or something.Code is below I've included all of it (sorry) for better ease of understanding the math that is happening:

HTML Code:

<form id="form1" action="" method="get">
<fieldset>
<p>[code]......

## Calculating Possible Routes Between Two Points

Oct 18, 2011

I am not a developer so not so familiar with javascript. Suppose I have a map with ten junctions and based on that map. I need to calculate all the possible routes between one junction to another. How do I represent the map in javascript and how do I code the function to calculate all the possible routes?

## Calculating Amount Of Time?

Nov 15, 2011

I was wondering if it is possible to figure out the amount of time passed from a specific time in history till the present? If so how? I have tried so many different things and I am not getting the right returns.

## Calculating The Scroll Area?

Jun 19, 2009

I am writing a DHTML application which uses AJAX to show dialogue windows etc.. (all the bells and whistles).When I display a DHTML dialogue in the foreground, I use JS to create a div which is a "layer" in between the foreground and the background which essentially "darkens" the background and disables all background functionality. Forcing the user to take action in the dialogue.How do I get the total scrollable area of the page so I know how big to make the "dark" div?I have tried all of these:

document.body.scrollWidth
document.body.scrollHeight
document.body.offsetWidth

[code]...

They all work in one browser or another, (I am testing in IE, FF and Opera) but none of them give me the correct values for the exact scrollable area of the page.

## Calculating A Score From A Row Of Drop-down Values

Aug 11, 2006

I need help in calculating a score from a row of drop-down values.
I need to use the onChange to tally the score as the user moves across
9 categories (with drop-down selection of 1-9 or N/A) multiplied by a
weighted score. The final column for each employee would be the
calculated score. I know how to accomplish this with vbscript but I
need it to process on the screen so the user can see the calculated
score as they make selections. Also the code needs to execute as many
times as there are employee rows.(loop) I don't know how to do this
with Javascript

Here's the VBscript with the variables involved
Var S1 = Category 1 Weighted score
Var S2 = Category 2 Weighted score
Var S3 = Category 3 Weighted score
Var S4 = Category 4 Weighted score
Var S5 = Category 5 Weighted score
Var S6 = Category 6 Weighted score
Var S7 = Category 7 Weighted score
Var S8 = Category 8 Weighted score
Var S9 = Category 9 Weighted score
D5 = 0.92
Var Q11 = Category 1 drop-down Value(1-9) * S1
Var Q22 = Category 2 drop-down Value(1-9) * S2
Var Q33 = Category 3 drop-down Value(1-9) * S3
Var Q44 = Category 4 drop-down Value(1-9) * S4

If (Category 5 Value = "N/A") THEN
Q55 = ' '
Else
Var Q55 = Category 5 drop-down Value(1-9 or N/A) * S5
End If

Var Q66 = Category 6 drop-down Value(1-9) * S6
Var Q77 = Category 7 drop-down Value(1-9) * S7
Var Q88 = Category 8 drop-down Value(1-9) * S8
Var Q99 = Category 9 drop-down Value(1-9) * S9

If (Category 5 = "N/A") THEN
Var FinalScore = round(((Q11 + Q22 + Q33 + Q44 + Q66 + Q77 + Q88 + Q99)
/ D5),2)
else
Var FinalScore = round((Q11 + Q22 + Q33 + Q44 + Q55 + Q66 + Q77 + Q88 +
Q99),2)
end if

Can anyone help me converting this to javascript?

## JQuery :: Calculating Value Based On Two Sliders?

Oct 14, 2009

I am trying to calculate a value based on two sliders.

This is the code that I am using:

var value1;
var value2;
\$(function() {

[Code]....