/    Sign up×
Community /Pin to ProfileBookmark

simple price calculation not working

[CODE]
<SCRIPT TYPE=”text/javascript”>
function Woo(){
var valu4 = (‘no’);
var valu1 = prompt(‘Hight in cm =’,’0′);
var valu2 = prompt(‘Width in cm =’,’0′);
var valu3 = prompt(‘Weight in grams =’,’0′);
var valu4 = prompt(‘is it a parcel yes or no’,’?’);

if ((valu1<32)&&(valu2<25)&&(valu3<100)){(price=’30p’);}
if ((valu1>31)||(valu2>24)&&(valu3<100)){(price=’50p’);}
if ((valu1<32)&&(valu2<25)&&(valu3<500)){(price=’60p’);}
if ((valu1>31)||(valu2>24)&&(valu3<500)){(price=’80p’);}
if ((valu3<1000)&&(valu3>499)){(price=’£3.00′);}
if ((valu4=’yes’)&&(valu3<500)){(price=’£1.65′);}

if (valu3>999)
{price=3;
valu3-1000;
valu3/500;}

alert(price);}

</SCRIPT>
<body onload=”Woo()”;
</body>
[/CODE]

this codes anoying me, i had it working yesterday, saved it, came back to it today.. and it died on me.
it only shows the value £1.65 every time…
please take a look and see if you could work out why this dosnt work XD
thanks in advance

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@Typhoon101May 25.2007 — You have a missing equals sign. When performing an if statement you must use 2 equals signs. Otherwise the value is assigned to the variable.

i.e.

(valu4=="no") means "If valu4 is equal to no"

(value4="no") means set valu4 to equal no.

[CODE]
<SCRIPT TYPE="text/javascript">
function Woo(){
var valu4 = ('no');
var valu1 = prompt('Hight in cm =','0');
var valu2 = prompt('Width in cm =','0');
var valu3 = prompt('Weight in grams =','0');
var valu4 = prompt('is it a parcel yes or no','?');

if ((valu1<32)&&(valu2<25)&&(valu3<100)){(price='30p');}
if ((valu1>31)||(valu2>24)&&(valu3<100)){(price='50p');}
if ((valu1<32)&&(valu2<25)&&(valu3<500)){(price='60p');}
if ((valu1>31)||(valu2>24)&&(valu3<500)){(price='80p');}
if ((valu3<1000)&&(valu3>499)){(price='&#1032;3.00');}
if ((valu4[COLOR=red][B]=[/B][/COLOR]='yes')&&(valu3<500)){(price='&#1032;1.65');}

if (valu3>999)
{price=3;
valu3-1000;
valu3/500;}

alert(price);}
</SCRIPT>
<body onload="Woo()";
</body>
[/CODE]
Copy linkTweet thisAlerts:
@RagedauthorMay 25.2007 — thanks alot =D works 100% now.

still think its weird way if saying if in a variable.

oh well =D thanks for the promt reply also
Copy linkTweet thisAlerts:
@RagedauthorJun 07.2007 — oh im sorry, one part dosnt work. the last part if (valu3&gt;999) {price=3; valu3-1000; valu3/500;} i need to make it so > 1kg £1 for each additional 500g im finding this very hard to work out how i can do it, any idea's?
Copy linkTweet thisAlerts:
@JMRKERJun 08.2007 — Either your formula is incorrect (remove the ';' after price=3; and put in correct operators between 3 segments)

or you have forgotten to make assignments (xx=valu3-100 and yy=valu3/500).

Sort of depends upon your intent.
Copy linkTweet thisAlerts:
@rootJun 08.2007 — I would also point out that their is a practical minimum size for a postage item, which I believe is A7 in size.

Items smaller than this will need to be packaged in a larger envelope or box. So your item could be a 2cm square box but the package could be an A5 jiffy bag for example and you would need to pay the postage price for sending an A5 package and not a 2cm square box...

So check because you could be losing out on your ACTUAL postage costs for postage...
×

Success!

Help @Raged spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...