|
You have omitted the braces around your if statements, in which case only the one single line following is executed.
if (DamascusBladePattern.value == "01") { // string literal values must be in quotes
document.images.Blade.src="http://www.petermartinknives.com/KnifeBuilder/Folder/SideView/Blade01.jpg";
BladePrice += 0;
}
It is recommended that you place the opening brace following the function, if, else, for, while, do, switch, and try statements on the same line and not on the following line.
<script language=javascript> is long deprecated. Use <script type = "text/javascript"> instead (in fact also deprecated but still necessary for IE<9).
The closing code tag is [/CODE]
Your code is defective in that if the user changes his mind and selects a different option the price of the newly selected blade is added to that of the previous selection. Move var BladePrice = 0; into the function.
document.write() is in effect obsolete. document.write() statements must be run before the page finishes loading. Any document.write() statement that runs after the page finishes loading will create a new page and overwrite all of the content of the current page (including the Javascript which called it). So document.write() is at best really only useful to write the original content of your page. It cannot be used to update the content of your page after that page has loaded.
To be candid, if this is a commercial site I would pay a professional to do it for you. There are many pitfalls in creating an e-commerce site. Presumably you would not attempt to service or repair a machine or appliance without any experience or understanding of how it worked.
A teacher informed my son that "There are two words which you should never use in school homework - one is cool and the other is gross". "No problem", replied the boy, "What are the two words?"
__________________
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Last edited by Philip M; 11-24-2012 at 01:35 PM..
|