Ok, I am trying to make a Custom Paypal order form with javascripting to eliminate the need for multiple orderforms. I have made the order form and so far it works except for one part. I have a drop down box that has the values ” ” “0” “2” “3” “4” for nameserver choice. upon clicking the box if you select 2 it adds $5.00 to the total, 3 adds $7.00 and 4 adds $10.00. That part works if you only select it once. If you select it again, it adds the value again. I am trying to figure out a way to reverse the original total then add the new total. I have tried several different methods (variables, hidden inputs) right now i have found that hidden inputs are working better for me but now i need to figure out how to do loops and gotos inside the actual function, i tried goTo() but that didnt work. I am going to copy the function that the dropdown uses and the code for the dropdown and all hidden values it works with. If anyone knows anything that might help me could you please offer it :
[QUOTE]
[B]The Html
<!–webbot bot=”Validation” s-display-name=”Nameservers” b-value-required=”TRUE” –><select onClick=”nsSet(this)” size=”1″ name=”os3″ id=”fp13″>
<option value=”-“>
<option value=”0″>0
<option value=”2″ >2
<option value=”3″ >3
<option value=”4″ >4</select>
<input type=”hidden” name=”nsset” value=”false”>
<input type=”hidden” name=”nsvalue” value=””>
<input type=”hidden” name=”a3″ value=”565.00″>
<input type=”hidden” name=”p3″ value=”22″>
<input type=”hidden” name=”t3″ value=”D”>
<input type=”hidden” name=”a1″ value=”565.00″>
<input type=”hidden” name=”p1″ value=”22″>
<input type=”hidden” name=”t1″ value=”D”>
[QUOTE]
[B]The Javascript Function
function nsSet(os3Field) {
if (document.myForm.nsset.value == “true”) {
if (document.myForm.nsvalue.value == “2”) {
document.myForm.a3.value=Math.floor(eval(document.myForm.a3.value)-5);
document.myForm.a1.value=Math.floor(eval(document.myForm.a3.value)-5);
document.myForm.price.value=’$’+document.myForm.a3.value;
document.myForm.total.value=’$’+document.myForm.a1.value;
document.myForm.nsset.value=’false’;
}
if (document.myForm.nsvalue.value == “3”) {
document.myForm.a3.value=Math.floor(eval(document.myForm.a3.value)-7);
document.myForm.a1.value=Math.floor(eval(document.myForm.a3.value)-7);
document.myForm.price.value=’$’+document.myForm.a3.value;
document.myForm.total.value=’$’+document.myForm.a1.value;
document.myForm.nsset.value=’false’;
}
if (document.myForm.nsvalue.value == “4”) {
document.myForm.a3.value=Math.floor(eval(document.myForm.a3.value)-10);
document.myForm.a1.value=Math.floor(eval(document.myForm.a3.value)-10);
document.myForm.price.value=’$’+document.myForm.a3.value;
document.myForm.total.value=’$’+document.myForm.a1.value;
document.myForm.nsset.value=’false’;
}
}
if (document.myForm.nsset.value == “false”) {
if (os3Field.value == “0”) {
document.myForm.nsprice.value=’$0.00′;
document.myForm.nsset.value=’true’;
document.myForm.nsvalue.value=’0′;
}
if (os3Field.value == “2”) {
var nsprices = “5”;
document.myForm.a3.value=Math.floor(eval(document.myForm.a3.value)+eval(nsprices))+’.00′;
document.myForm.a1.value=Math.floor(eval(document.myForm.a1.value)+eval(nsprices))+’.00′;
document.myForm.nsprice.value=’$5.00′;
document.myForm.price.value=’$’+document.myForm.a3.value;
document.myForm.total.value=’$’+document.myForm.a1.value;
document.myForm.nsset.value=’true’;
document.myForm.nsvalue.value=’3′;
}
if (os3Field.value == “3”) {
var nsprices = “7”;
document.myForm.a3.value=Math.floor(eval(document.myForm.a3.value)+eval(nsprices))+’.50′;
document.myForm.a1.value=Math.floor(eval(document.myForm.a1.value)+eval(nsprices))+’.50′;
document.myForm.nsprice.value=’$7.00′;
document.myForm.price.value=’$’+document.myForm.a3.value;
document.myForm.total.value=’$’+document.myForm.a1.value;
document.myForm.nsset.value=’true’;
document.myForm.nsvalue.value=’3′;
}
if (os3Field.value == 4) {
var nsprices = “10”
document.myForm.a3.value=Math.floor(eval(document.myForm.a3.value)+eval(nsprices))+’.00′;
document.myForm.a1.value=Math.floor(eval(document.myForm.a1.value)+eval(nsprices))+’.00′;
document.myForm.nsprice.value=’$10.00′;
document.myForm.price.value=’$’+document.myForm.a3.value;
document.myForm.total.value=’$’+document.myForm.a1.value;
document.myForm.nsset.value=’true’;
document.myForm.nsvalue.value=’4′;
}
}
}