Jump to content

MBCUK

New Members
  • Posts

    7
  • Joined

  • Last visited

MBCUK's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <script> function calculatePrice(totalItems) { if (totalItems < 1) { return 0; } if (totalItems <= 35) { return 49; } // we have more then 35 items // the first 35 go for 49 pound // all others (totalItems - 35) go for 0.85 return 49 + (totalItems - 35) * 0.85; } function updatePricesOnClick(form) { form.pricePerUnit.value = calculatePricePerUnit(form.totalItems.value); form.price.value = calculatePrice(form.totalItems.value); } </script> <form action="#"> <input type="text" name="totalItems" id="totalItems"> <input type="text" name="pricePerUnit" id="pricePerUnit"> <input type="text" name="price" id="price"> <input type="submit" onclick="updatePricesOnClick(this.parentElement); return false;"> </form> Is this correct?
  2. Sorry can I ask, how do I assign varibles so I can create a form for someone to input their own number of items...
  3. ok.. I can understand this better! Thanks!
  4. I think for I might be aiming a bit high as far as my courwork is concerned, but thanks I really do appreciate the adivce I will look at php.net at least ive got 4 months to finish my website
  5. thankyou. should I google how to do this using php or stick to javascript. I have to change the numbers into varibles with an input form
  6. Hi there, I am trying to learn how to make a calculation script. I first started out trying to ask people online on javascript forums but for some reason no-one is very keen on helping me. I am not a coder or in work I am 16 and trying to create this for my ICT coursework, I am now afriad ive bitten off more than I can chew.. Basically, I have done the research as far as my forumulae is comcerend but I am having difficulties putting it all together onto a website. Please dont shoot me if this isnt correct but this is my forumlae example Math.round(400*(49+Math.max(count-35;0)*0.85)/count)/400 this is the problem im trying to solve: £49 for the first 35 items £0.85 each item thereafter user inputs total amount of items eg 400 items 400 items - 35 = 365 365 * 0.85 = 310.25 310.25 + 49 = 359.25 Total Price £359.25 Then the total price £359.25 / 400 to give the price per item £0.89 (to two decimal places) I really nope someone can help me out here or its back to the drawing bord
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.