eiger23
03-05-2012, 04:58 PM
I have a small price quote calculator/contact information form. I want the customer to fill out the whole form submit it, and get his/her estimated price based on selections in the form.
I am using asp, and I have a javascript for the quote calculations. My question is how would I take this js and execute it when the user hits submit, and then display that quote price on the next page. Here is the javascript that I'm working with:
var practice_field = new Array();
practice_field["None"]=0;
practice_field["Allergy and Immunology"]=4400;
practice_field["Endocrinology"]=4400;
practice_field["Pathology"]=4400;
practice_field["Dermatology"]=4400;
practice_field["Geriatrics"]=4400;
practice_field["Physical Rehabilitation"]=4400;
practice_field["Family Practice"]=6900;
practice_field["General Practice"]=6900;
practice_field["Internal Medicine"]=6900;
practice_field["Oncology"]=6900;
practice_field["Oral Surgery"]=6900;
practice_field["Radiology"]=6900;
practice_field["Gastroenterology"]=6900;
practice_field["Infectious Disease"]=6900;
practice_field["Nephrology"]=6900;
practice_field["Ophthalmology"]=6900;
practice_field["Pediatrics"]=6900;
practice_field["Urology"]=6900;
practice_field["Anesthesiology"]=9000;
practice_field["Cosmetic Surgery"]=9000;
practice_field["General Surgery"]=9000;
practice_field["Neurology"]=9000;
practice_field["Otolaryngology"]=9000;
practice_field["Plastic Surgery"]=9000;
practice_field["Vascular Surgery"]=9000;
practice_field["Cardiology"]=9000;
practice_field["Emergency Medicine"]=9000;
practice_field["Gynecology"]=9000;
practice_field["Orthopedic Surgery"]=9000;
practice_field["Pain Management"]=9000;
practice_field["Pulmonary Surgery"]=9000;
practice_field["Neurological Surgery"]=9900;
practice_field["Obstetrics"]=9900;
var society_member= new Array();
society_member["None"]=null;
society_member["BCMA"]=0.10;
society_member["DCMA"]=0.10;
society_member["FOGS"]=0.10;
society_member["FNS"]=0.10;
society_member["PBCMS"]=0.10;
society_member["FSPS"]=0.10;
function getPracticeField()
{
var docPracticeField=0;
var theForm = document.forms["quoteform"];
var selectedPracticeField = theForm.elements["practice"];
docPracticeField = practice_field[selectedPracticeField.value];
return docPracticeField;
}
function getSelectedSociety()
{
var docSelectedSociety=0;
var theForm = document.forms["quoteform"];
var selectedSociety = theForm.elements["society"];
docSelectedSociety = society_member[selectedSociety.value];
return docSelectedSociety;
}
function bareDefensePrice()
{
var defensePrice=0;
var theForm = document.forms["quoteform"];
var includeDefense = theForm.elements["baredefense"];
if(includeDefense.checked==true)
{
defensePrice=0;
}
return defensePrice;
}
function insuranceDefensePrice()
{
var insuranceDefense=0;
var theForm = document.forms["quoteform"];
var includeMoreDefense = theForm.elements["insureddefense"];
if(includeMoreDefense.checked==true){
insuranceDefense=0;
}
return insuranceDefense;
}
function calculateTotal()
{
var defensePrice = getPracticeField() + null - (getPracticeField() * getSelectedSociety()) + bareDefensePrice() + insuranceDefensePrice();
var divobj = document.getElementById('totalPrice');
divobj.style.display='block';
divobj.innerHTML = "Your Pre-Paid Legal Defense Fee Will Be Around $"+defensePrice;
}
function hideTotal()
{
var divobj = document.getElementById('totalPrice');
divobj.style.display='none';
}
here is the html:
<body onload='hideTotal()'>
<div id="wrap">
<form action="" id="quoteform" onsubmit="">
<div>
<div class="cont_order">
<fieldset>
<legend>How Much Will My Pre-Paid Legal Defense Cost?</legend>
<label >Choose Your Practice Field</label>
<select id="practice" name='practice' onchange="calculateTotal()">
<option value="None">Select Field</option>
<option value="Allergy and Immunology">Allergy and Immunology</option>
<option value="Endocrinology">Endocrinology</option>
<option value="Pathology">Pathology</option>
<option value="Dermatology">Dermatology</option>
<option value="Geriatrics">Geriatrics</option>
<option value="Physical Rehabilitation">Physical Rehabilitation</option>
<option value="Family Practice">Family Practice</option>
<option value="General Practice">General Practice</option>
<option value="Internal Medicine">Internal Medicine</option>
<option value="Oncology">Oncology</option>
<option value="Oral Surgery">Oral Surgery</option>
<option value="Radiology">Radiology</option>
<option value="Gastroenterology">Gastroenterology</option>
<option value="Infectious Disease">Infectious Disease</option>
<option value="Nephrology">Nephrology</option>
<option value="Ophthalmology">Ophthalmology</option>
<option value="Pediatrics">Pediatrics</option>
<option value="Urology">Urology</option>
<option value="Anesthesiology">Anesthesiology</option>
<option value="Cosmetic Surgery">Cosmetic Surgery</option>
<option value="General Surgery">General Surgery</option>
<option value="Neurology">Neurology</option>
<option value="Otolaryngology">Otolaryngology</option>
<option value="Plastic Surgery">Plastic Surgery</option>
<option value="Vascular Surgery">Vascular Surgery</option>
<option value="Cardiology">Cardiology</option>
<option value="Emergency Medicine">Emergency Medicine</option>
<option value="Gynecology">Gynecology</option>
<option value="Orthopedic Surgery">Orthopedic Surgery</option>
<option value="Pain Management">Pain Management</option>
<option value="Pulmonary Surgery">Pulmonary Surgery</option>
<option value="Neurological Surgery">Neurological Surgery</option>
<option value="Obstetrics">Obstetrics</option>
</select>
<br/>
<p>
<label >Are You Affiliated With Any of the Following Medical Societies</label>
<select id="society" name='society' onchange="calculateTotal()">
<option value="None">Select Society</option>
<option value="None">No, I am not</option>
<option value="BCMA">Broward County Medical Association</option>
<option value="DCMA">Dade County Medical Association</option>
<option value="FOGS">Florida Obstetrics & Gynecology Society</option>
<option value="FNS">Florida Neurological Society</option>
<option value="PBCMS">Palm Beach County Medical Society</option>
<option value="FSPS">Florida Society of Plastic Surgeons</option>
</select>
</p>
<br/>
<label >What Type of Defense Are You Interested In?</label>
<br />
<label for='baredefense' class="inlinelabel">Bare Defense</label>
<input type="checkbox" id="baredefense" name='baredefense' onclick="calculateTotal()" />
<br />
<label class="inlinelabel" for='insureddefense'>Insured Defense</label>
<input type="checkbox" id="insureddefense" name="insureddefense" onclick="calculateTotal()" />
</p>
<div id="totalPrice"></div>
</fieldset>
</div>
<div class="cont_details">
<fieldset>
<legend>Contact Details</legend>
<label for='name'>Name</label>
<input type="text" id="name" name='name' />
<br/>
<label for='address'>Address</label>
<input type="text" id="address" name='address' />
<br/>
<label for='phonenumber'>Phone Number</label>
<input type="text" id="phonenumber" name='phonenumber'/>
<br/>
</fieldset>
</div>
<input type='submit' id='submit' value='Calculate Rate' onclick="calculateTotal()" />
</div>
</form>
</div><!--End of wrap-->
I am using asp, and I have a javascript for the quote calculations. My question is how would I take this js and execute it when the user hits submit, and then display that quote price on the next page. Here is the javascript that I'm working with:
var practice_field = new Array();
practice_field["None"]=0;
practice_field["Allergy and Immunology"]=4400;
practice_field["Endocrinology"]=4400;
practice_field["Pathology"]=4400;
practice_field["Dermatology"]=4400;
practice_field["Geriatrics"]=4400;
practice_field["Physical Rehabilitation"]=4400;
practice_field["Family Practice"]=6900;
practice_field["General Practice"]=6900;
practice_field["Internal Medicine"]=6900;
practice_field["Oncology"]=6900;
practice_field["Oral Surgery"]=6900;
practice_field["Radiology"]=6900;
practice_field["Gastroenterology"]=6900;
practice_field["Infectious Disease"]=6900;
practice_field["Nephrology"]=6900;
practice_field["Ophthalmology"]=6900;
practice_field["Pediatrics"]=6900;
practice_field["Urology"]=6900;
practice_field["Anesthesiology"]=9000;
practice_field["Cosmetic Surgery"]=9000;
practice_field["General Surgery"]=9000;
practice_field["Neurology"]=9000;
practice_field["Otolaryngology"]=9000;
practice_field["Plastic Surgery"]=9000;
practice_field["Vascular Surgery"]=9000;
practice_field["Cardiology"]=9000;
practice_field["Emergency Medicine"]=9000;
practice_field["Gynecology"]=9000;
practice_field["Orthopedic Surgery"]=9000;
practice_field["Pain Management"]=9000;
practice_field["Pulmonary Surgery"]=9000;
practice_field["Neurological Surgery"]=9900;
practice_field["Obstetrics"]=9900;
var society_member= new Array();
society_member["None"]=null;
society_member["BCMA"]=0.10;
society_member["DCMA"]=0.10;
society_member["FOGS"]=0.10;
society_member["FNS"]=0.10;
society_member["PBCMS"]=0.10;
society_member["FSPS"]=0.10;
function getPracticeField()
{
var docPracticeField=0;
var theForm = document.forms["quoteform"];
var selectedPracticeField = theForm.elements["practice"];
docPracticeField = practice_field[selectedPracticeField.value];
return docPracticeField;
}
function getSelectedSociety()
{
var docSelectedSociety=0;
var theForm = document.forms["quoteform"];
var selectedSociety = theForm.elements["society"];
docSelectedSociety = society_member[selectedSociety.value];
return docSelectedSociety;
}
function bareDefensePrice()
{
var defensePrice=0;
var theForm = document.forms["quoteform"];
var includeDefense = theForm.elements["baredefense"];
if(includeDefense.checked==true)
{
defensePrice=0;
}
return defensePrice;
}
function insuranceDefensePrice()
{
var insuranceDefense=0;
var theForm = document.forms["quoteform"];
var includeMoreDefense = theForm.elements["insureddefense"];
if(includeMoreDefense.checked==true){
insuranceDefense=0;
}
return insuranceDefense;
}
function calculateTotal()
{
var defensePrice = getPracticeField() + null - (getPracticeField() * getSelectedSociety()) + bareDefensePrice() + insuranceDefensePrice();
var divobj = document.getElementById('totalPrice');
divobj.style.display='block';
divobj.innerHTML = "Your Pre-Paid Legal Defense Fee Will Be Around $"+defensePrice;
}
function hideTotal()
{
var divobj = document.getElementById('totalPrice');
divobj.style.display='none';
}
here is the html:
<body onload='hideTotal()'>
<div id="wrap">
<form action="" id="quoteform" onsubmit="">
<div>
<div class="cont_order">
<fieldset>
<legend>How Much Will My Pre-Paid Legal Defense Cost?</legend>
<label >Choose Your Practice Field</label>
<select id="practice" name='practice' onchange="calculateTotal()">
<option value="None">Select Field</option>
<option value="Allergy and Immunology">Allergy and Immunology</option>
<option value="Endocrinology">Endocrinology</option>
<option value="Pathology">Pathology</option>
<option value="Dermatology">Dermatology</option>
<option value="Geriatrics">Geriatrics</option>
<option value="Physical Rehabilitation">Physical Rehabilitation</option>
<option value="Family Practice">Family Practice</option>
<option value="General Practice">General Practice</option>
<option value="Internal Medicine">Internal Medicine</option>
<option value="Oncology">Oncology</option>
<option value="Oral Surgery">Oral Surgery</option>
<option value="Radiology">Radiology</option>
<option value="Gastroenterology">Gastroenterology</option>
<option value="Infectious Disease">Infectious Disease</option>
<option value="Nephrology">Nephrology</option>
<option value="Ophthalmology">Ophthalmology</option>
<option value="Pediatrics">Pediatrics</option>
<option value="Urology">Urology</option>
<option value="Anesthesiology">Anesthesiology</option>
<option value="Cosmetic Surgery">Cosmetic Surgery</option>
<option value="General Surgery">General Surgery</option>
<option value="Neurology">Neurology</option>
<option value="Otolaryngology">Otolaryngology</option>
<option value="Plastic Surgery">Plastic Surgery</option>
<option value="Vascular Surgery">Vascular Surgery</option>
<option value="Cardiology">Cardiology</option>
<option value="Emergency Medicine">Emergency Medicine</option>
<option value="Gynecology">Gynecology</option>
<option value="Orthopedic Surgery">Orthopedic Surgery</option>
<option value="Pain Management">Pain Management</option>
<option value="Pulmonary Surgery">Pulmonary Surgery</option>
<option value="Neurological Surgery">Neurological Surgery</option>
<option value="Obstetrics">Obstetrics</option>
</select>
<br/>
<p>
<label >Are You Affiliated With Any of the Following Medical Societies</label>
<select id="society" name='society' onchange="calculateTotal()">
<option value="None">Select Society</option>
<option value="None">No, I am not</option>
<option value="BCMA">Broward County Medical Association</option>
<option value="DCMA">Dade County Medical Association</option>
<option value="FOGS">Florida Obstetrics & Gynecology Society</option>
<option value="FNS">Florida Neurological Society</option>
<option value="PBCMS">Palm Beach County Medical Society</option>
<option value="FSPS">Florida Society of Plastic Surgeons</option>
</select>
</p>
<br/>
<label >What Type of Defense Are You Interested In?</label>
<br />
<label for='baredefense' class="inlinelabel">Bare Defense</label>
<input type="checkbox" id="baredefense" name='baredefense' onclick="calculateTotal()" />
<br />
<label class="inlinelabel" for='insureddefense'>Insured Defense</label>
<input type="checkbox" id="insureddefense" name="insureddefense" onclick="calculateTotal()" />
</p>
<div id="totalPrice"></div>
</fieldset>
</div>
<div class="cont_details">
<fieldset>
<legend>Contact Details</legend>
<label for='name'>Name</label>
<input type="text" id="name" name='name' />
<br/>
<label for='address'>Address</label>
<input type="text" id="address" name='address' />
<br/>
<label for='phonenumber'>Phone Number</label>
<input type="text" id="phonenumber" name='phonenumber'/>
<br/>
</fieldset>
</div>
<input type='submit' id='submit' value='Calculate Rate' onclick="calculateTotal()" />
</div>
</form>
</div><!--End of wrap-->