Price calculator and rounding

I am currently using a price calculator - although it's really not a calculator; I have to enter every price manually. Currently, it works in half inch increments.

I need it to do two things that it doesn't do currently:
1) Allow the customer to enter a dimension in 1/4 inch increments (1/8 would be even better, but I'm not requesting a miracle)
2) Make the result automatically round up to the nearest 1/2 inch

[URL="http://www.stadriemblems.com/auto-quote.html"]Page containing calculator[/URL]

[URL="http://www.stadriemblems.com/sizecalc.js"]External file: sizecalc.js[/URL]
LVL 1
MarisaWeb DesignAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

plusone3055Commented:
if you have it already working in 1/2  increments why use the same fuction * .5   and then again *.25 for 1/4 and 1/8 increments

and for your rounding...
http://www.javascriptkit.com/javatutors/round.shtml

:)
0
MarisaWeb DesignAuthor Commented:
Sounds simple enough, however, I should have clarified that I know very little about JavaScript syntax; I took this code for somewhere else. Could you maybe be a little more specific in your explanation? Is this fuction * .5 that you refer to a setting in sizecalc.js?

Thank you!!!
0
plusone3055Commented:
thank you for clarifying :)


hold on a min lemmie look thorugh the script

can you please post the entire HTML page so i can see how you are referencing the javascript please
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

MarisaWeb DesignAuthor Commented:
Yes, the first link I posted is the entire html page.
0
plusone3055Commented:
okay here in your auto_quote.htm
to get it in 1/8 increments :)

Change this code
lines 11500 -11508

      if (ok){
                        size = (parseFloat($('patch_width').value) + parseFloat($('patch_length').value)) / 2;
                        temp_size = size - Math.floor(size);
                        if (temp_size > 0.5){
                              size = Math.ceil(size);
                        }
                        else if (temp_size > 0 && temp_size <= 0.5){
                              size = Math.floor(size) + 0.5;
                        }
==========================================================================
To THIS

      if (ok){
                        size = (parseFloat($('patch_width').value) + parseFloat($('patch_length').value)) / 8;
                        temp_size = size - Math.floor(size);
                        if (temp_size > 0.125){
                              size = Math.ceil(size);
                        }
                        else if (temp_size > 0 && temp_size <= 0.125){
                              size = Math.floor(size) + 0.125;
                        }
0
MarisaWeb DesignAuthor Commented:
Thanks! That works in a way, however, when I put in .125 x .5 it gives me a total of 1.

Or when I put in a total of .125 x 8 it gives me a total of 3.

So it's not doing the math correctly. Do I also need to edit the sizecalc.js file?
0
plusone3055Commented:
it is doing the match correctly you have to decide how the users need to enter the data..

Currently, it works in half inch increments.

I need it to do two things that it doesn't do currently:
1) Allow the customer to enter a dimension in 1/4 inch increments (1/8 would be even better, but I'm not requesting a miracle)


it was doing it in 1/2 inches
so that means  that if a user was entering 2 into the field that would be 1 whole inch

now its doing it in 1/8 inch each number is 1/8
so 8 = 1
0
MarisaWeb DesignAuthor Commented:
Well that's no good. 8 needs to = 8. So is there not a way to do this then?
0
plusone3055Commented:
if (ok){
                        size = (parseFloat($('patch_width').value) + parseFloat($('patch_length').value)) / 1;
                        temp_size = size - Math.floor(size);
                        if (temp_size > 0.0){
                              size = Math.ceil(size);
                        }
                        else if (temp_size > 0 && temp_size <= 0.0){
                              size = Math.floor(size) + 0.0;
                        }


for 8 = 8
0
MarisaWeb DesignAuthor Commented:
Cool, thanks! Do I replace this or add it? I told you, I am JavaRetarded, hahaha
0
plusone3055Commented:
your welcome
to answer your question replace

   if (ok){
                        size = (parseFloat($('patch_width').value) + parseFloat($('patch_length').value)) / 8;
                        temp_size = size - Math.floor(size);
                        if (temp_size > 0.125){
                              size = Math.ceil(size);
                        }
                        else if (temp_size > 0 && temp_size <= 0.125){
                              size = Math.floor(size) + 0.125;
                        }
=========================
WITH THIS
========================

if (ok){
                        size = (parseFloat($('patch_width').value) + parseFloat($('patch_length').value)) / 1;
                        temp_size = size - Math.floor(size);
                        if (temp_size > 0.0){
                              size = Math.ceil(size);
                        }
                        else if (temp_size > 0 && temp_size <= 0.0){
                              size = Math.floor(size) + 0.0;
                        }


0
MarisaWeb DesignAuthor Commented:
Boy, I really feel like I'm being a nuisance. Replacing that code gives the sum of the two dimensions rather than the average like it was doing before.
0
plusone3055Commented:
   if (ok){
                        size = (parseFloat($('patch_width').value) + parseFloat($('patch_length').value)) / 2;
                        temp_size = size - Math.floor(size);
                        if (temp_size > 0.0){
                              size = Math.ceil(size);
                        }
                        else if (temp_size > 0 && temp_size <= 0.0){
                              size = Math.floor(size) + 0.0;
                        }
0
MarisaWeb DesignAuthor Commented:
Great! That worked! I should only have one more question. it's back to not working if I put in any increment smaller than .5.
0
plusone3055Commented:
if (ok){
                        size = (parseFloat($('patch_width').value) + parseFloat($('patch_length').value)) / 2;
                        temp_size = size - Math.floor(size);
                        if (temp_size > 0.5){
                              size = Math.ceil(size);
                        }
                        else if (temp_size > 0 && temp_size <= 0.5){
                              size = Math.floor(size) + 0.5;
                        }
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MarisaWeb DesignAuthor Commented:
Was very patient with my ignorance and didn't give up.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.