Forum Moderators: open
Can anyone tell me what it is without seeing the actual javascript and html? If you need to, I can give ya a link to check it out. Thanks!
Josh
function changePrice() {
var totalPrice;
totalPrice = 0;
if ((document.orderForm.model.F1) ¦¦ (document.orderForm.model.F2)) {
totalPrice = 225;
} else {
if ((document.orderForm.model.F3) ¦¦ (document.orderForm.model.F4)) {
totalPrice = 250;
} else {
if ((document.orderForm.model.F1) ¦¦ (document.orderForm.model.F6)) totalPrice = 275;
}
}
if ((document.orderForm.handles[1].checked) ¦¦ (document.orderForm.handles[2].checked)) {
totalPrice += 50;
} else {
if (document.orderForm.handles[3].checked) totalPrice += 150;
}
if (document.orderForm.blade[1].checked) totalPrice += 150;
if ((document.orderForm.bolsters[2].checked) ¦¦ (document.orderForm.bolsters[3].checked)) {
totalPrice += 75;
} else {
if (document.orderForm.bolsters[1].checked) totalPrice += 30;
}
if (document.orderForm.fileWork.checked == true) {
totalPrice += 50;
}
document.subTotal.innerHTML = "$" + totalPrice;
function changePrice() {
var totalPrice;
totalPrice = 0;
if ((document.orderForm.model[document.orderForm.model.selectedIndex].value == 'Model F1') ¦¦ (document.orderForm.model[document.orderForm.model.selectedIndex].value == 'Model F2')) {
totalPrice = 225;
} elseif ((document.orderForm.model[document.orderForm.model.selectedIndex].value == 'Model F3') ¦¦ (document.orderForm.model[document.orderForm.model.selectedIndex].value == 'Model F4')) {
totalPrice = 250;
} elseif ((document.orderForm.model[document.orderForm.model.selectedIndex].value == 'Model F5') ¦¦ (document.orderForm.model[document.orderForm.model.selectedIndex].value == 'Model F6')) {
totalPrice = 275;
}
if ((document.orderForm.handles[1].checked) ¦¦ (document.orderForm.handles[2].checked)) {
totalPrice += 50;
} elseif (document.orderForm.handles[3].checked) {
totalPrice += 150;
}
if (document.orderForm.blade[1].checked) {
totalPrice += 150;
}
if ((document.orderForm.bolsters[2].checked) ¦¦ (document.orderForm.bolsters[3].checked)) {
totalPrice += 75;
} elseif (document.orderForm.bolsters[1].checked) {
totalPrice += 30;
}
if (document.orderForm.fileWork.checked == true) {
totalPrice += 50;
}
document.subTotal.innerHTML = "$" + totalPrice;
i think this will do it, it is the way you get the value from your drop down you have to do
document.orderForm.model[document.orderForm.model.selectedIndex].value == 'Model F1'
The sub total is a div tag with a name="subTotal" attribute. The script then tries to change the innerHTML of the div tag like follows:
document.orderForm.subTotal.innerHTML = totalPrice
The blue bit is the problem. The 'orderForm' (<form name="orderform">) collection only contains true form elements for scripting purposes - so input tags and textareas are pretty much all you get to through the form itself.
This is easily fixed by giving your div tag an id="subTotal" attribute.
document.getElementById('subTotal').innerHTML = totalPrice However this might not be the best solution. You may be better to make the subtotal div a real form input. This way it will reset correctly when somebody clicks the reset button and it will also be more cross-browser friendly as not all browsers can handle the innerHTML property change (nn4 and possibly Opera).
Finally your
<SELECT name=model>needs a
onchange="changePrice()"attribute and your script should be all ok.
Let me know if you get it working... best of luck
Josh
Josh
if (document.orderForm.model.selectedIndex == 4) {
for (loop= 1; loop < 4; loop++)
document.orderForm.handles[loop].disabled = true;
document.orderForm.handles[0].checked = true;
}
}
But it doesn't seem to do anything. That is exactly how I did it in the last script I did that did this, but it doesn't seem to work this time. What's going on? I'm clueless again ^_^
Josh