Jessee
asked on
Javascript for each certain amount, increase variable
Hi there,
I am needing to calculate shipping in a website I am writing. Each item we sell has a maxshipping variable which shows how many of that item can be shipped before the items shipping cost is increased.
E.g.
An item has a shipping cost of $0.60 for up to 10 of the items... After that 10 I want to increase it by another $0.60... then so forth for each 10 items.
How do I go about doing this?
Thanks,
Jessee
I am needing to calculate shipping in a website I am writing. Each item we sell has a maxshipping variable which shows how many of that item can be shipped before the items shipping cost is increased.
E.g.
An item has a shipping cost of $0.60 for up to 10 of the items... After that 10 I want to increase it by another $0.60... then so forth for each 10 items.
How do I go about doing this?
Thanks,
Jessee
ASKER
Hi there,
Yes.
1 - 10 items = 0.60
11 - 20 items = 1.20 etc etc...
Will try this code and get back to you.
Thanks,
Jessee
Yes.
1 - 10 items = 0.60
11 - 20 items = 1.20 etc etc...
Will try this code and get back to you.
Thanks,
Jessee
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey there,
The maxshipping changes with each item. Sometimes only 2 items can be sent for 0.60... other times 10 items can be. How do I include that?
Thanks,
Jessee
The maxshipping changes with each item. Sometimes only 2 items can be sent for 0.60... other times 10 items can be. How do I include that?
Thanks,
Jessee
Did you try it? If you add 1 through 10 in the qty box, it will be 60 cents. If you use 11 through 20 it will be 1.20.
ASKER
Works like a charm. Just needed to put the maxshipping in where the /10 was.
Thank you!
Thank you!
Hi @Letsgetcoding
For 25 it has to 1.80 right?
For 25 it has to 1.80 right?
now if it have only one item it would be also $0.60 right ?
please confirm.
If yes please copy below code and save it as "test.html".
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>love to marry </title>
<meta name="Generator" content="Lorem ipsum dolor sit amet,">
<meta name="Author" content=" consectetur.adipisicing,">
<meta name="Keywords" content="sed do eiusmod tempor incididunt">
<meta name="Description" content="ut labore et dolore magna aliqua.">
<script type="text/javascript">
function bridedress()
{
var item_no =25;
var cost = 0.60;
var quantity =10;
var extra = 0;
var item = 0;
var totalprice =0 ;
var extraitem =0 ;
extraitem = (item_no%quantity);
item = Math.floor(item_no/quantit
if(extraitem < quantity)
{
extra = 1;// to keep additional item less than 10 as 1 unit or quantity
}
totalprice = (item*cost)+(extra*cost);
alert(totalprice)
alert(item)
alert(extra*cost)
}
</script>
</head>
<body>
<a href="javascript:bridedres
</body>
</html>
(Edit: Possible advertising removed - Modulus_Twelve)