
Originally Posted by
nick120
function calctotal() {
var x=500;
if (document.nick.radio1[1].checked==true)
x=x+125;
if (document.nick.radio2[1].checked==true)
x=x+100;
if (document.nick.radio3[1].checked==true)
x=x+50;
document.nick.totalfield.value=x;
}
This can be simplified slightly:
Code:
function calcTotal() {
var x = 500,
e = document.forms.nick.elements;
if(e.radio1[1].checked) {x += 125;}
if(e.radio2[1].checked) {x += 100;}
if(e.radio3[1].checked) {x += 50;}
e.totalfield.value = x;
}
function Check_Data() {
if(document.nick.radio1[1].checked==true)
if(document.nick.radio2[1].checked==true)
if(document.nick.radio3[1].checked==true) {
alert("Form Completed Successfully");
return true;
} else {
alert("You Have not made a upgraded selection do u wish to continue?");
return false;
}
}
It seems that you're trying to check that one of them is selected. If you add the appropriate braces, you'll see that this isn't the case:
Code:
function checkData() {
var e = document.forms.nick.elements;
if(e.radio1[1].checked) {
if(e.radio2[1].checked) {
if(e.radio3[1].checked) {
return true;
} else {
alert('Please made a selection before continuing.');
return false;
}
}
}
}
What you're probably looking for is:
Code:
function checkData() {
var e = document.forms.nick.elements;
if(e.radio1[1].checked || e.radio2[1].checked || e.radio3[1].checked) {
return true;
} else {
alert('Please made a selection before continuing.');
return false;
}
}
i cant figure out how to calculate the total what am i missing?
You haven't shown what you're trying to total, so any suggestions would nothing beyond guesses. Please post a URL to an example of what you're trying to do.
Mike
Bookmarks