Click to See Complete Forum and Search --> : Need help making this work!!
mattward
12-22-2002, 04:16 PM
Hello,
I am a true newbie with Javascript. I am attempting to make an estimator that will give a price quote to someone selecting from the dropdowns.
Could anyone please tell me how to get the function pricecalc working in this script?
Ideally if you select all of the first options from the drop downs the price should show as $5.00
Any help would be greatly appreciated.
ESTIMATOR (http://www.centralmasswebdesign.com/stellarsports/estimator.htm)
Thanks Much,
Matt
AdamBrill
12-22-2002, 11:18 PM
Hey!
I'm working on trying to get your script to work... But, I have a few questions. First of all, did you type all of the script in?? Or did something generate it?? I need you to tell me exactly what you want the script to do. In the code, you have a form named form1, and inside that form, you have a OPTION tag called shirtqty. What is this for? In the script, you have MANY different values for this(12,36,72,144,500,1000), but in the form, it has only 2 values(Level1 and Level2). The only two choices that it COULD return are Level1 and Level2, but you have many different choices, none of which are Level1 or Level2. What is up with that??? Also, you have a different OPTION tag called nbrcolor. This one also has 6 choices in the script, but in the OPTION tag, it only has 2. I must know what the other choices are, or it won't work. If you don't know what I mean by all of this, let me know and I will try to explain it better... But, the good news is that beside there being more choices in the script than in the tag, it is working! If I do one of the choices that are there, it works. So, if you tell me the other options, I should have it working in no time...
mattward
12-23-2002, 07:47 AM
Adam,
Thanks for your help.
The reason that there are many more choices in the script than in the fields was because I just put a few in the fields to get it to work. Eventually, everything that is in the script will need to be in the dropdowns.
First dropdown is type:
name - value
Select - select
Heavy - heavy
Beefy - beefy
Second is shirtqty
name - value
12-35 - 12
36-71 - 36
72-143 - 72
144-499 - 144
500 - 1000 - 500
1000+ - 1000
Third is shirtcolor
name - value
white - white
light - light
dark - dark
fourth is nbrcolor
name - value
1color - 1
2color - 2
3color - 3
4color - 4
5color - 5
6color - 6
the intention of the script is to find the price for each possible iteration above. I entered the prices into the script.
I typed in the entire script, nothing generated it.
AdamBrill
12-23-2002, 08:17 AM
Yo!
Here's the code... If you have any other questions, let me know. Also, when you generate the price, some of the answers have quotation marks around them and some of them don't. I would take all of them out. It will make it a lot easier to generate the total. If you need help getting the total to work, let me know...
mattward
12-23-2002, 08:27 AM
DUDE!!!!
YOUR AWESOME!!!! Thanks....
How do I get the price field to format in 2 decimals...like
$5.50
right now it comes up as 5.5
AdamBrill
12-23-2002, 08:49 AM
You know how I told you to take out the quotation marks??? Well, you have to put them back in. Sorry... I didn't know exactly what you wanted... The line should look something like this...
document.form1.price.value = "$5.50";
Anything that you put inside of the quotes is what will be in the text box. When you figure out the total, you will have to take off the $ and turn the rest into a number... If you need to know how to do that, let me know...
mattward
12-23-2002, 08:51 AM
I do need to know how to do that...
I was just going to eval quantity.value and price.value and add the two together.
I guess you can't do that, huh?
AdamBrill
12-23-2002, 09:47 AM
Here's the new code... When you change the value of the quantity textbox, it calculates the total. I don't know if that is how you want it or not, but it is easy to change. It seemed to work right for me, but if it doesn't work for you, let me know, and I'll try to fix it... If you have any other questions, just ask.
mattward
12-23-2002, 10:05 AM
Adam,
Everything seems to be working as I originally intended.
I want to take this opportunity to thank you for all of the help that you provided me for this challenge.
You are the epitamy of what I wish all forum users would be. Have yourself a wonderful holiday!!!
Regards
Matt
AdamBrill
12-23-2002, 10:32 AM
Anytime Matt, I'm glad I could help. If you have any other questions, just ask... Happy Holidays, Adam