javascript confusion - please help

The following javascript function is called from a form in dreamweaver.


It passes 5 values to the function, current_value and new_value being verified numeric, the remainder being alpha-numeric. A number of variables are declared, these are assigned values throughout the script.

The script is in 3 parts, which part is used depends on the value of variable transtype. The script builds and returns 2 array messages, repb & repbb to dreamweaver calling page.

The problem is that the script does not work, it fails to even activate the first alert box. Can someone please check the code and advise if it is wrong and how it can be corrected. Thank-you.


function calcQuote(transtype, current_value, new_value, salelease, buylease) {
var i,buyi,buyx,repb,repbb,stampd,landfee,buyvat,sellvat,solfeeb,solfees,replyout,buytot,selltot;
window.alert('got here');
if (transtype = 'buy') {
window.alert(transtype);
if (salelease == 'freehold') {solfeeb = 550 buyvat = 96}
else {solfeeb = 650 buyvat = 114};
if (new_value < 120000) {stampd = 0};
if (new_value >= 120001 && new_value <= 250000) {stampd = (new_value/100)};
if (new_value >= 250001 && new_value <= 500000) (stampd = (new_value/100)*3};
if (new_value >= 500001) {stampd = (new_value/25)};
if (new_value < 50000) {landfee = 0};
If (new_value >= 50001 && new_value <= 80000) {landfee = 60};
if (new_value >= 80001 && new_value <= 100000) {landfee = 100};
if (new_value >= 100001 && new_value <= 150000) {landfee = 150};
if (new_value >= 150001 && new_value <= 200000) {landfee = 220};
if (new_value >= 200001 && new_value <= 500000) {landfee = 420};
if (new_value >= 500001) {landfee = 700};
buytot = ((stampd + landfee) + (solfeeb + buyvat) + 254)
buyi = 0;
buyx = 0;
var repb = new Array ("output Header line"," ",
"Gross Cost:","Tax @ 17.5%:", "Local check:**",
"Water check:","bank Search:", "Registration Fee:",
"Land Search:","Land Tax:", "Enviromental Search:",
"Bank Fees:","TOTAL:","** Local search fees vary. ",
"The quoted figure is the","maximum you can exoect to pay "," ");
var buyi = repb.length;
alert("array length is "+buyil);
repbb = new Array (" "," ",solfeesb,buyvat,135,40,4,landfee,stampd,40,35," ",buytot," ");
var buyx = repbb.length;
}
if (transtype = 'sell') {
window.alert(transtype);
if (salelease == 'freehold') {solfees = 550 sellvat = 96};
else {solfees = 650 sellvat = 114};
buyi = 0;
buyx = 0;
var repb = new Array ("Gross cost:"," ","Fees","TAX @ 17.5%",
"Office copies","Bank fees"," TOTAL:");
var buyi = reps.length;
var selltot = ((solfees + sellvat) + 39)
var repbb = new Array (" "," ",solfees,sellvat,4,35,selltot);
var buyx = repss.length;
};
if (transtype = 'both') (
window.alert(transtype);
if (salelease == 'freehold') {solfeeb = 550 buyvat = 96};
else {solfeeb = 650 buyvat = 114};
if (new_value < 120000) {stampd = 0};
if (new_value >= 120001 && new_value <= 250000) {stampd = (new_value/100)};
if (new_value >= 250001 && new_value <= 500000) (stampd = (new_value/100)*3};
if (new_value >= 500001) {stampd = (new_value/25)};
if (new_value < 50000) {landfee = 0};
If (new_value >= 50001 && new_value <= 80000) {landfee = 60};
if (new_value >= 80001 && new_value <= 100000) {landfee = 100};
if (new_value >= 100001 && new_value <= 150000) {landfee = 150};
if (new_value >= 150001 && new_value <= 200000) {landfee = 220};
if (new_value >= 200001 && new_value <= 500000) {landfee = 420};
if (new_value >= 500001) {landfee = 700};
buytot = ((stampd + landfee) + (solfeeb + buyvat) + 254);
if (salelease == 'freehold') {solfees = 550 sellvat = 96};
else {solfees = 650 sellvat = 114};
buyi = 0;
buyx = 0;
var repb = new Array ("Header line 1 "," ",
"Gross Cost:","TAX @ 17.5%:", "Local Search:**",
"Water Search:","Bank Search:", "Fee:",
"Land Search:","Land Tax:", "Enviromental Search:",
"Bank Fees:","TOTAL 1:","** Local fees can vary",
"The quoted figure is the","maximum you can expect to pay"," "," ",
"Quote for acting on a sale"," ","Gross Fees 2","TAX @ 17.5%",
"Office copies","Bank fees","TOTAL:");
var buyi = repb.length;
alert("array length is "+buyil);
repbb = new Array (" "," ",solfeesb,buyvat,135,40,4,landfee,stampd,40,35," ",buytot," ",
" "," "," "," ",solfees,sellvat,4,35,selltot);
var buyx = repbb.length;
};
alert(repd,repbb);
document.returnValue = (repd,repbb);

Comments

  • : The following javascript function is called from a form in dreamweaver.
    :
    :
    : It passes 5 values to the function, current_value and new_value being verified numeric, the remainder being alpha-numeric. A number of variables are declared, these are assigned values throughout the script.
    :
    : The script is in 3 parts, which part is used depends on the value of variable transtype. The script builds and returns 2 array messages, repb & repbb to dreamweaver calling page.
    :
    : The problem is that the script does not work, it fails to even activate the first alert box. Can someone please check the code and advise if it is wrong and how it can be corrected. Thank-you.
    :
    :
    : function calcQuote(transtype, current_value, new_value, salelease, buylease) {
    : var i,buyi,buyx,repb,repbb,stampd,landfee,buyvat,sellvat,solfeeb,solfees,replyout,buytot,selltot;
    : window.alert('got here');
    : if (transtype = 'buy') {
    : window.alert(transtype);
    : if (salelease == 'freehold') {solfeeb = 550 buyvat = 96}
    : else {solfeeb = 650 buyvat = 114};
    : if (new_value < 120000) {stampd = 0};
    : if (new_value >= 120001 && new_value <= 250000) {stampd = (new_value/100)};
    : if (new_value >= 250001 && new_value <= 500000) (stampd = (new_value/100)*3};
    : if (new_value >= 500001) {stampd = (new_value/25)};
    : if (new_value < 50000) {landfee = 0};
    : If (new_value >= 50001 && new_value <= 80000) {landfee = 60};
    : if (new_value >= 80001 && new_value <= 100000) {landfee = 100};
    : if (new_value >= 100001 && new_value <= 150000) {landfee = 150};
    : if (new_value >= 150001 && new_value <= 200000) {landfee = 220};
    : if (new_value >= 200001 && new_value <= 500000) {landfee = 420};
    : if (new_value >= 500001) {landfee = 700};
    : buytot = ((stampd + landfee) + (solfeeb + buyvat) + 254)
    : buyi = 0;
    : buyx = 0;
    : var repb = new Array ("output Header line"," ",
    : "Gross Cost:","Tax @ 17.5%:", "Local check:**",
    : "Water check:","bank Search:", "Registration Fee:",
    : "Land Search:","Land Tax:", "Enviromental Search:",
    : "Bank Fees:","TOTAL:","** Local search fees vary. ",
    : "The quoted figure is the","maximum you can exoect to pay "," ");
    : var buyi = repb.length;
    : alert("array length is "+buyil);
    : repbb = new Array (" "," ",solfeesb,buyvat,135,40,4,landfee,stampd,40,35," ",buytot," ");
    : var buyx = repbb.length;
    : }
    : if (transtype = 'sell') {
    : window.alert(transtype);
    : if (salelease == 'freehold') {solfees = 550 sellvat = 96};
    : else {solfees = 650 sellvat = 114};
    : buyi = 0;
    : buyx = 0;
    : var repb = new Array ("Gross cost:"," ","Fees","TAX @ 17.5%",
    : "Office copies","Bank fees"," TOTAL:");
    : var buyi = reps.length;
    : var selltot = ((solfees + sellvat) + 39)
    : var repbb = new Array (" "," ",solfees,sellvat,4,35,selltot);
    : var buyx = repss.length;
    : };
    : if (transtype = 'both') (
    : window.alert(transtype);
    : if (salelease == 'freehold') {solfeeb = 550 buyvat = 96};
    : else {solfeeb = 650 buyvat = 114};
    : if (new_value < 120000) {stampd = 0};
    : if (new_value >= 120001 && new_value <= 250000) {stampd = (new_value/100)};
    : if (new_value >= 250001 && new_value <= 500000) (stampd = (new_value/100)*3};
    : if (new_value >= 500001) {stampd = (new_value/25)};
    : if (new_value < 50000) {landfee = 0};
    : If (new_value >= 50001 && new_value <= 80000) {landfee = 60};
    : if (new_value >= 80001 && new_value <= 100000) {landfee = 100};
    : if (new_value >= 100001 && new_value <= 150000) {landfee = 150};
    : if (new_value >= 150001 && new_value <= 200000) {landfee = 220};
    : if (new_value >= 200001 && new_value <= 500000) {landfee = 420};
    : if (new_value >= 500001) {landfee = 700};
    : buytot = ((stampd + landfee) + (solfeeb + buyvat) + 254);
    : if (salelease == 'freehold') {solfees = 550 sellvat = 96};
    : else {solfees = 650 sellvat = 114};
    : buyi = 0;
    : buyx = 0;
    : var repb = new Array ("Header line 1 "," ",
    : "Gross Cost:","TAX @ 17.5%:", "Local Search:**",
    : "Water Search:","Bank Search:", "Fee:",
    : "Land Search:","Land Tax:", "Enviromental Search:",
    : "Bank Fees:","TOTAL 1:","** Local fees can vary",
    : "The quoted figure is the","maximum you can expect to pay"," "," ",
    : "Quote for acting on a sale"," ","Gross Fees 2","TAX @ 17.5%",
    : "Office copies","Bank fees","TOTAL:");
    : var buyi = repb.length;
    : alert("array length is "+buyil);
    : repbb = new Array (" "," ",solfeesb,buyvat,135,40,4,landfee,stampd,40,35," ",buytot," ",
    : " "," "," "," ",solfees,sellvat,4,35,selltot);
    : var buyx = repbb.length;
    : };
    : alert(repd,repbb);
    : document.returnValue = (repd,repbb);
    :
    :
    You don't need to predefine the variables. Like in basic, the variables are created as needed. I think a statement as the first var doesn't run in javascript.
  • : : The following javascript function is called from a form in dreamweaver.
    : :
    : :
    : : It passes 5 values to the function, current_value and new_value being verified numeric, the remainder being alpha-numeric. A number of variables are declared, these are assigned values throughout the script.
    : :
    : : The script is in 3 parts, which part is used depends on the value of variable transtype. The script builds and returns 2 array messages, repb & repbb to dreamweaver calling page.
    : :
    : : The problem is that the script does not work, it fails to even activate the first alert box. Can someone please check the code and advise if it is wrong and how it can be corrected. Thank-you.
    : :
    : :
    : : function calcQuote(transtype, current_value, new_value, salelease, buylease) {
    : : var i,buyi,buyx,repb,repbb,stampd,landfee,buyvat,sellvat,solfeeb,solfees,replyout,buytot,selltot;
    : : window.alert('got here');
    : : if (transtype = 'buy') {
    : : window.alert(transtype);
    : : if (salelease == 'freehold') {solfeeb = 550 buyvat = 96}
    : : else {solfeeb = 650 buyvat = 114};
    : : if (new_value < 120000) {stampd = 0};
    : : if (new_value >= 120001 && new_value <= 250000) {stampd = (new_value/100)};
    : : if (new_value >= 250001 && new_value <= 500000) (stampd = (new_value/100)*3};
    : : if (new_value >= 500001) {stampd = (new_value/25)};
    : : if (new_value < 50000) {landfee = 0};
    : : If (new_value >= 50001 && new_value <= 80000) {landfee = 60};
    : : if (new_value >= 80001 && new_value <= 100000) {landfee = 100};
    : : if (new_value >= 100001 && new_value <= 150000) {landfee = 150};
    : : if (new_value >= 150001 && new_value <= 200000) {landfee = 220};
    : : if (new_value >= 200001 && new_value <= 500000) {landfee = 420};
    : : if (new_value >= 500001) {landfee = 700};
    : : buytot = ((stampd + landfee) + (solfeeb + buyvat) + 254)
    : : buyi = 0;
    : : buyx = 0;
    : : var repb = new Array ("output Header line"," ",
    : : "Gross Cost:","Tax @ 17.5%:", "Local check:**",
    : : "Water check:","bank Search:", "Registration Fee:",
    : : "Land Search:","Land Tax:", "Enviromental Search:",
    : : "Bank Fees:","TOTAL:","** Local search fees vary. ",
    : : "The quoted figure is the","maximum you can exoect to pay "," ");
    : : var buyi = repb.length;
    : : alert("array length is "+buyil);
    : : repbb = new Array (" "," ",solfeesb,buyvat,135,40,4,landfee,stampd,40,35," ",buytot," ");
    : : var buyx = repbb.length;
    : : }
    : : if (transtype = 'sell') {
    : : window.alert(transtype);
    : : if (salelease == 'freehold') {solfees = 550 sellvat = 96};
    : : else {solfees = 650 sellvat = 114};
    : : buyi = 0;
    : : buyx = 0;
    : : var repb = new Array ("Gross cost:"," ","Fees","TAX @ 17.5%",
    : : "Office copies","Bank fees"," TOTAL:");
    : : var buyi = reps.length;
    : : var selltot = ((solfees + sellvat) + 39)
    : : var repbb = new Array (" "," ",solfees,sellvat,4,35,selltot);
    : : var buyx = repss.length;
    : : };
    : : if (transtype = 'both') (
    : : window.alert(transtype);
    : : if (salelease == 'freehold') {solfeeb = 550 buyvat = 96};
    : : else {solfeeb = 650 buyvat = 114};
    : : if (new_value < 120000) {stampd = 0};
    : : if (new_value >= 120001 && new_value <= 250000) {stampd = (new_value/100)};
    : : if (new_value >= 250001 && new_value <= 500000) (stampd = (new_value/100)*3};
    : : if (new_value >= 500001) {stampd = (new_value/25)};
    : : if (new_value < 50000) {landfee = 0};
    : : If (new_value >= 50001 && new_value <= 80000) {landfee = 60};
    : : if (new_value >= 80001 && new_value <= 100000) {landfee = 100};
    : : if (new_value >= 100001 && new_value <= 150000) {landfee = 150};
    : : if (new_value >= 150001 && new_value <= 200000) {landfee = 220};
    : : if (new_value >= 200001 && new_value <= 500000) {landfee = 420};
    : : if (new_value >= 500001) {landfee = 700};
    : : buytot = ((stampd + landfee) + (solfeeb + buyvat) + 254);
    : : if (salelease == 'freehold') {solfees = 550 sellvat = 96};
    : : else {solfees = 650 sellvat = 114};
    : : buyi = 0;
    : : buyx = 0;
    : : var repb = new Array ("Header line 1 "," ",
    : : "Gross Cost:","TAX @ 17.5%:", "Local Search:**",
    : : "Water Search:","Bank Search:", "Fee:",
    : : "Land Search:","Land Tax:", "Enviromental Search:",
    : : "Bank Fees:","TOTAL 1:","** Local fees can vary",
    : : "The quoted figure is the","maximum you can expect to pay"," "," ",
    : : "Quote for acting on a sale"," ","Gross Fees 2","TAX @ 17.5%",
    : : "Office copies","Bank fees","TOTAL:");
    : : var buyi = repb.length;
    : : alert("array length is "+buyil);
    : : repbb = new Array (" "," ",solfeesb,buyvat,135,40,4,landfee,stampd,40,35," ",buytot," ",
    : : " "," "," "," ",solfees,sellvat,4,35,selltot);
    : : var buyx = repbb.length;
    : : };
    : : alert(repd,repbb);
    : : document.returnValue = (repd,repbb);
    : :
    : :
    : You don't need to predefine the variables. Like in basic, the variables are created as needed. I think a statement as the first var doesn't run in javascript.
    :

    Thank you, I removed the variable declaration but it still doesn't run. Dreamweaver verifies the number fields and reports if non- numeric chrs entered. If I comment out this script those functions work, however with this script running no scripts work and the status bar reports 'error on page'. Getting even more confused. I wanna go back to COBOL!
  • : : : The following javascript function is called from a form in dreamweaver.
    : : :
    : : :
    : : : It passes 5 values to the function, current_value and new_value being verified numeric, the remainder being alpha-numeric. A number of variables are declared, these are assigned values throughout the script.
    : : :
    : : : The script is in 3 parts, which part is used depends on the value of variable transtype. The script builds and returns 2 array messages, repb & repbb to dreamweaver calling page.
    : : :
    : : : The problem is that the script does not work, it fails to even activate the first alert box. Can someone please check the code and advise if it is wrong and how it can be corrected. Thank-you.
    : : :
    : : :
    : : : function calcQuote(transtype, current_value, new_value, salelease, buylease) {
    : : : var i,buyi,buyx,repb,repbb,stampd,landfee,buyvat,sellvat,solfeeb,solfees,replyout,buytot,selltot;
    : : : window.alert('got here');
    : : : if (transtype = 'buy') {
    : : : window.alert(transtype);
    : : : if (salelease == 'freehold') {solfeeb = 550 buyvat = 96}
    : : : else {solfeeb = 650 buyvat = 114};
    : : : if (new_value < 120000) {stampd = 0};
    : : : if (new_value >= 120001 && new_value <= 250000) {stampd = (new_value/100)};
    : : : if (new_value >= 250001 && new_value <= 500000) (stampd = (new_value/100)*3};
    : : : if (new_value >= 500001) {stampd = (new_value/25)};
    : : : if (new_value < 50000) {landfee = 0};
    : : : If (new_value >= 50001 && new_value <= 80000) {landfee = 60};
    : : : if (new_value >= 80001 && new_value <= 100000) {landfee = 100};
    : : : if (new_value >= 100001 && new_value <= 150000) {landfee = 150};
    : : : if (new_value >= 150001 && new_value <= 200000) {landfee = 220};
    : : : if (new_value >= 200001 && new_value <= 500000) {landfee = 420};
    : : : if (new_value >= 500001) {landfee = 700};
    : : : buytot = ((stampd + landfee) + (solfeeb + buyvat) + 254)
    : : : buyi = 0;
    : : : buyx = 0;
    : : : var repb = new Array ("output Header line"," ",
    : : : "Gross Cost:","Tax @ 17.5%:", "Local check:**",
    : : : "Water check:","bank Search:", "Registration Fee:",
    : : : "Land Search:","Land Tax:", "Enviromental Search:",
    : : : "Bank Fees:","TOTAL:","** Local search fees vary. ",
    : : : "The quoted figure is the","maximum you can exoect to pay "," ");
    : : : var buyi = repb.length;
    : : : alert("array length is "+buyil);
    : : : repbb = new Array (" "," ",solfeesb,buyvat,135,40,4,landfee,stampd,40,35," ",buytot," ");
    : : : var buyx = repbb.length;
    : : : }
    : : : if (transtype = 'sell') {
    : : : window.alert(transtype);
    : : : if (salelease == 'freehold') {solfees = 550 sellvat = 96};
    : : : else {solfees = 650 sellvat = 114};
    : : : buyi = 0;
    : : : buyx = 0;
    : : : var repb = new Array ("Gross cost:"," ","Fees","TAX @ 17.5%",
    : : : "Office copies","Bank fees"," TOTAL:");
    : : : var buyi = reps.length;
    : : : var selltot = ((solfees + sellvat) + 39)
    : : : var repbb = new Array (" "," ",solfees,sellvat,4,35,selltot);
    : : : var buyx = repss.length;
    : : : };
    : : : if (transtype = 'both') (
    : : : window.alert(transtype);
    : : : if (salelease == 'freehold') {solfeeb = 550 buyvat = 96};
    : : : else {solfeeb = 650 buyvat = 114};
    : : : if (new_value < 120000) {stampd = 0};
    : : : if (new_value >= 120001 && new_value <= 250000) {stampd = (new_value/100)};
    : : : if (new_value >= 250001 && new_value <= 500000) (stampd = (new_value/100)*3};
    : : : if (new_value >= 500001) {stampd = (new_value/25)};
    : : : if (new_value < 50000) {landfee = 0};
    : : : If (new_value >= 50001 && new_value <= 80000) {landfee = 60};
    : : : if (new_value >= 80001 && new_value <= 100000) {landfee = 100};
    : : : if (new_value >= 100001 && new_value <= 150000) {landfee = 150};
    : : : if (new_value >= 150001 && new_value <= 200000) {landfee = 220};
    : : : if (new_value >= 200001 && new_value <= 500000) {landfee = 420};
    : : : if (new_value >= 500001) {landfee = 700};
    : : : buytot = ((stampd + landfee) + (solfeeb + buyvat) + 254);
    : : : if (salelease == 'freehold') {solfees = 550 sellvat = 96};
    : : : else {solfees = 650 sellvat = 114};
    : : : buyi = 0;
    : : : buyx = 0;
    : : : var repb = new Array ("Header line 1 "," ",
    : : : "Gross Cost:","TAX @ 17.5%:", "Local Search:**",
    : : : "Water Search:","Bank Search:", "Fee:",
    : : : "Land Search:","Land Tax:", "Enviromental Search:",
    : : : "Bank Fees:","TOTAL 1:","** Local fees can vary",
    : : : "The quoted figure is the","maximum you can expect to pay"," "," ",
    : : : "Quote for acting on a sale"," ","Gross Fees 2","TAX @ 17.5%",
    : : : "Office copies","Bank fees","TOTAL:");
    : : : var buyi = repb.length;
    : : : alert("array length is "+buyil);
    : : : repbb = new Array (" "," ",solfeesb,buyvat,135,40,4,landfee,stampd,40,35," ",buytot," ",
    : : : " "," "," "," ",solfees,sellvat,4,35,selltot);
    : : : var buyx = repbb.length;
    : : : };
    : : : alert(repd,repbb);
    : : : document.returnValue = (repd,repbb);
    : : :
    : : :
    : : You don't need to predefine the variables. Like in basic, the variables are created as needed. I think a statement as the first var doesn't run in javascript.
    : :
    :
    : Thank you, I removed the variable declaration but it still doesn't run. Dreamweaver verifies the number fields and reports if non- numeric chrs entered. If I comment out this script those functions work, however with this script running no scripts work and the status bar reports 'error on page'. Getting even more confused. I wanna go back to COBOL!
    :
    Perhaps you made some typos or changed the cases of names. Javascript is case sensitive. You can double click on the statusbar symbol to get more info on the error it encountered.
  • I'm not sure what it suppose to do but here is working version:
    [code]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


    TestJs

    function calcQuote(transtype, current_value, new_value, salelease, buylease) {
    var i,buyi,buyx,repb,repbb,stampd,landfee,buyvat,sellvat,solfeeb,solfees,replyout,buytot,selltot;
    window.alert('got here');
    if (transtype = 'buy') {
    window.alert(transtype);
    if (salelease == 'freehold') {solfeeb = 550; buyvat = 96;}
    else {solfeeb = 650; buyvat = 114;}
    if (new_value < 120000) {stampd = 0}
    if (new_value >= 120001 && new_value <= 250000) {stampd = (new_value/100)}
    if (new_value >= 250001 && new_value <= 500000) {stampd = (new_value/100)*3}
    if (new_value >= 500001) {stampd = (new_value/25)};
    if (new_value < 50000) {landfee = 0;}
    if (new_value >= 50001 && new_value <= 80000) {landfee = 60;}
    if (new_value >= 80001 && new_value <= 100000) {landfee = 100;}
    if (new_value >= 100001 && new_value <= 150000) {landfee = 150;}
    if (new_value >= 150001 && new_value <= 200000) {landfee = 220;}
    if (new_value >= 200001 && new_value <= 500000) {landfee = 420;}
    if (new_value >= 500001) {landfee = 700;}
    buytot = ((stampd + landfee) + (solfeeb + buyvat) + 254)
    buyi = 0;
    buyx = 0;
    var repb = new Array ("output Header line"," ",
    "Gross Cost:","Tax @ 17.5%:", "Local check:**",
    "Water check:","bank Search:", "Registration Fee:",
    "Land Search:","Land Tax:", "Enviromental Search:",
    "Bank Fees:","TOTAL:","** Local search fees vary. ",
    "The quoted figure is the","maximum you can exoect to pay "," ");
    var buyi = repb.length;
    alert("array length is "+buyi);
    repbb = new Array (" "," ",solfeeb,buyvat,135,40,4,landfee,stampd,40,35," ",buytot," ");
    var buyx = repbb.length;
    }
    if (transtype = 'sell') {
    window.alert(transtype);
    if (salelease == 'freehold') {solfees = 550; sellvat = 96;}
    else {solfees = 650; sellvat = 114;}
    buyi = 0;
    buyx = 0;
    var repbb = new Array ("Gross cost:"," ","Fees","TAX @ 17.5%",
    "Office copies","Bank fees"," TOTAL:");
    var buyi = repb.length;
    var selltot = ((solfees + sellvat) + 39);
    var repbb = new Array (" "," ",solfees,sellvat,4,35,selltot);
    var buyx = repbb.length;
    };
    if (transtype = 'both'){
    alert(transtype);
    if (salelease == 'freehold') {solfeeb = 550; buyvat = 96;}
    else {solfeeb = 650; buyvat = 114;}
    if (new_value < 120000) {stampd = 0;}
    if (new_value >= 120001 && new_value <= 250000) {stampd = (new_value/100);}
    if (new_value >= 250001 && new_value <= 500000) {stampd = (new_value/100)*3;}
    if (new_value >= 500001) {stampd = (new_value/25);}
    if (new_value < 50000) {landfee = 0;}
    if (new_value >= 50001 && new_value <= 80000) {landfee = 60;}
    if (new_value >= 80001 && new_value <= 100000) {landfee = 100;}
    if (new_value >= 100001 && new_value <= 150000) {landfee = 150;}
    if (new_value >= 150001 && new_value <= 200000) {landfee = 220;}
    if (new_value >= 200001 && new_value <= 500000) {landfee = 420;}
    if (new_value >= 500001) {landfee = 700;}
    buytot = ((stampd + landfee) + (solfeeb + buyvat) + 254);
    if (salelease == 'freehold') {solfees = 550; sellvat = 96;}
    else {solfees = 650; sellvat = 114;}
    buyi = 0;
    buyx = 0;
    var repb = new Array ("Header line 1 "," ",
    "Gross Cost:","TAX @ 17.5%:", "Local Search:**",
    "Water Search:","Bank Search:", "Fee:",
    "Land Search:","Land Tax:", "Enviromental Search:",
    "Bank Fees:","TOTAL 1:","** Local fees can vary",
    "The quoted figure is the","maximum you can expect to pay"," "," ",
    "Quote for acting on a sale"," ","Gross Fees 2","TAX @ 17.5%",
    "Office copies","Bank fees","TOTAL:");
    var buyi = repb.length;
    alert("array length is "+buyi);
    repbb = new Array (" "," ",solfees,buyvat,135,40,4,landfee,stampd,40,35," ",buytot," ",
    " "," "," "," ",solfees,sellvat,4,35,selltot);
    var buyx = repbb.length;
    };
    alert(repb,repbb);
    document.returnValue = (repb,repbb);
    }







    [code]
  • : I'm not sure what it suppose to do but here is working version:
    : [code]
    : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    :
    :
    : TestJs
    :
    : function calcQuote(transtype, current_value, new_value, salelease, buylease) {
    : var i,buyi,buyx,repb,repbb,stampd,landfee,buyvat,sellvat,solfeeb,solfees,replyout,buytot,selltot;
    : window.alert('got here');
    : if (transtype = 'buy') {
    : window.alert(transtype);
    : if (salelease == 'freehold') {solfeeb = 550; buyvat = 96;}
    : else {solfeeb = 650; buyvat = 114;}
    : if (new_value < 120000) {stampd = 0}
    : if (new_value >= 120001 && new_value <= 250000) {stampd = (new_value/100)}
    : if (new_value >= 250001 && new_value <= 500000) {stampd = (new_value/100)*3}
    : if (new_value >= 500001) {stampd = (new_value/25)};
    : if (new_value < 50000) {landfee = 0;}
    : if (new_value >= 50001 && new_value <= 80000) {landfee = 60;}
    : if (new_value >= 80001 && new_value <= 100000) {landfee = 100;}
    : if (new_value >= 100001 && new_value <= 150000) {landfee = 150;}
    : if (new_value >= 150001 && new_value <= 200000) {landfee = 220;}
    : if (new_value >= 200001 && new_value <= 500000) {landfee = 420;}
    : if (new_value >= 500001) {landfee = 700;}
    : buytot = ((stampd + landfee) + (solfeeb + buyvat) + 254)
    : buyi = 0;
    : buyx = 0;
    : var repb = new Array ("output Header line"," ",
    : "Gross Cost:","Tax @ 17.5%:", "Local check:**",
    : "Water check:","bank Search:", "Registration Fee:",
    : "Land Search:","Land Tax:", "Enviromental Search:",
    : "Bank Fees:","TOTAL:","** Local search fees vary. ",
    : "The quoted figure is the","maximum you can exoect to pay "," ");
    : var buyi = repb.length;
    : alert("array length is "+buyi);
    : repbb = new Array (" "," ",solfeeb,buyvat,135,40,4,landfee,stampd,40,35," ",buytot," ");
    : var buyx = repbb.length;
    : }
    : if (transtype = 'sell') {
    : window.alert(transtype);
    : if (salelease == 'freehold') {solfees = 550; sellvat = 96;}
    : else {solfees = 650; sellvat = 114;}
    : buyi = 0;
    : buyx = 0;
    : var repbb = new Array ("Gross cost:"," ","Fees","TAX @ 17.5%",
    : "Office copies","Bank fees"," TOTAL:");
    : var buyi = repb.length;
    : var selltot = ((solfees + sellvat) + 39);
    : var repbb = new Array (" "," ",solfees,sellvat,4,35,selltot);
    : var buyx = repbb.length;
    : };
    : if (transtype = 'both'){
    : alert(transtype);
    : if (salelease == 'freehold') {solfeeb = 550; buyvat = 96;}
    : else {solfeeb = 650; buyvat = 114;}
    : if (new_value < 120000) {stampd = 0;}
    : if (new_value >= 120001 && new_value <= 250000) {stampd = (new_value/100);}
    : if (new_value >= 250001 && new_value <= 500000) {stampd = (new_value/100)*3;}
    : if (new_value >= 500001) {stampd = (new_value/25);}
    : if (new_value < 50000) {landfee = 0;}
    : if (new_value >= 50001 && new_value <= 80000) {landfee = 60;}
    : if (new_value >= 80001 && new_value <= 100000) {landfee = 100;}
    : if (new_value >= 100001 && new_value <= 150000) {landfee = 150;}
    : if (new_value >= 150001 && new_value <= 200000) {landfee = 220;}
    : if (new_value >= 200001 && new_value <= 500000) {landfee = 420;}
    : if (new_value >= 500001) {landfee = 700;}
    : buytot = ((stampd + landfee) + (solfeeb + buyvat) + 254);
    : if (salelease == 'freehold') {solfees = 550; sellvat = 96;}
    : else {solfees = 650; sellvat = 114;}
    : buyi = 0;
    : buyx = 0;
    : var repb = new Array ("Header line 1 "," ",
    : "Gross Cost:","TAX @ 17.5%:", "Local Search:**",
    : "Water Search:","Bank Search:", "Fee:",
    : "Land Search:","Land Tax:", "Enviromental Search:",
    : "Bank Fees:","TOTAL 1:","** Local fees can vary",
    : "The quoted figure is the","maximum you can expect to pay"," "," ",
    : "Quote for acting on a sale"," ","Gross Fees 2","TAX @ 17.5%",
    : "Office copies","Bank fees","TOTAL:");
    : var buyi = repb.length;
    : alert("array length is "+buyi);
    : repbb = new Array (" "," ",solfees,buyvat,135,40,4,landfee,stampd,40,35," ",buytot," ",
    : " "," "," "," ",solfees,sellvat,4,35,selltot);
    : var buyx = repbb.length;
    : };
    : alert(repb,repbb);
    : document.returnValue = (repb,repbb);
    : }
    :
    :
    :
    :
    :
    :
    :
    : [code]
    :

    Thank-you to everybody who replied. You have all been very helpful.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories