`;
// Append the new entry to the container
productEntries.appendChild(newEntry);
}
function addProductEntry2() {
var productEntries = document.getElementById('SPLASHBACK-Ss');
// Create a new product entry div
var newEntry = document.createElement('div');
newEntry.classList.add('SPLASHBACK-S');
// Add input fields for the new entry
newEntry.innerHTML = `
`;
// Append the new entry to the container
productEntries.appendChild(newEntry);
}
function addProductEntry3() {
var productEntries = document.getElementById('UPSTAND-S');
// Create a new product entry div
var newEntry = document.createElement('div');
newEntry.classList.add('UPSTAND-Sc');
// Add input fields for the new entry
newEntry.innerHTML = `
`;
// Append the new entry to the container
productEntries.appendChild(newEntry);
}
function addProductEntry4() {
var productEntries = document.getElementById('WINDOWSILL-S');
// Create a new product entry div
var newEntry = document.createElement('div');
// Add input fields for the new entry
newEntry.classList.add('WINDOWSILL-Sc');
newEntry.innerHTML = `
`;
// Append the new entry to the container
productEntries.appendChild(newEntry);
}
function removeProductEntry(button) {
// Get the parent div and remove it
var entry = button.parentNode;
entry.parentNode.removeChild(entry);
}
function calculateTotalAreaw() {
var entries = document.querySelectorAll('.WORKTOP-S');
var totalAreaw = 0;
// Iterate through each entry and calculate area
entries.forEach(function(entry) {
var width = parseFloat(entry.querySelector('#worktop-w').value) || 0;
var height = parseFloat(entry.querySelector('#worktop-h').value) || 0;
// Calculate area for each entry and add to total
var area = width * height;
area = area/1000000;
totalAreaw += area;
});
// Display the total area on the page
document.getElementById('worktopsum').innerText = totalAreaw.toFixed(2);
}
function calculateTotalAreas() {
var entriess = document.querySelectorAll('.SPLASHBACK-S');
var totalAreas = 0;
// Iterate through each entry and calculate area
entriess.forEach(function(entry) {
var widths = parseFloat(entry.querySelector('#splashback-w').value) || 0;
var heights = parseFloat(entry.querySelector('#splashback-h').value) || 0;
// Calculate area for each entry and add to total
var areas = widths * heights;
areas = areas/1000000;
totalAreas += areas;
});
// Display the total area on the page
document.getElementById('splashsum').innerText = totalAreas.toFixed(2);
}
function validateForm() {
// Add your validation logic here for each required field
var field1Value = document.querySelector('input[name="material"]').value;
var field2Value = document.querySelector('input[name="name"]').value;
var field3Value = document.querySelector('input[name="email"]').value;
var field4Value = document.querySelector('input[name="TemplateFixing"]:checked').value;
var field5Value = document.querySelector('input[name="trader"]:checked').value;
var field6Value = document.querySelector('input[name="planner"]:checked').value;
var fileInputs = document.querySelectorAll('input[name="uploadplannerinput[]"]');
var field8Value = document.querySelector('input[name="traderName"]').value;
var field9Value = document.querySelector('textarea[name="usercomments"]').value;
// Check if the values are not empty
if (field1Value.trim() === "" || field2Value.trim() === "" || field3Value.trim() === "" || field4Value.trim() === "" || field5Value.trim() === "" || field6Value.trim() === "") {
return false;
}
if (field6Value == 1) {
// Check if at least one file has been selected in each file input field
var hasFiles = Array.from(fileInputs).some(function(input) {
return input.files.length > 0;
});
if (!hasFiles) {
return false;
}
}
if (field5Value == 1 && field8Value.trim() === "") {
return false;
}
// Add more validation checks for other required fields
return true; // Return true if all validations pass
}
function toggleTraderNameInput(show) {
var traderNameInput = document.getElementById('traderNameInput');
var traderNameField = document.getElementById('traderName');
if (show) {
traderNameInput.style.display = 'block';
traderNameField.required = true; // Make the field required if shown
} else {
traderNameInput.style.display = 'none';
traderNameField.required = false; // Make the field optional if hidden
}
}
function plannerInput(show) {
var uploadplannerdiv = document.getElementById('uploadplannerdiv');
var uploadplannerdiv1 = document.getElementById('uploadplannerdiv1');
var uploadplannerinputs = document.querySelectorAll('input[name="uploadplannerinput[]"]');
var calculatorplannerdiv = document.getElementById('calculatorplannerdiv');
var usercomments = document.getElementById('usercomments');
var myForm = document.getElementById("calculatorForm");
var calculatedoption = document.getElementById("calculatedoption");
calculatedoption.style.display = 'block';
if (show) {
uploadplannerdiv.style.display = 'block';
uploadplannerdiv1.style.display = 'block';
calculatorplannerdiv.style.display = 'none';
// Make all file input fields required if shown
uploadplannerinputs.forEach(function(input) {
input.required = true;
});
usercomments.required = false; // Make the field required if shown
// Set the action attribute of the form
myForm.action = "https://marbletops.co.uk/mail.php";
} else if (!show) {
uploadplannerdiv.style.display = 'none';
uploadplannerdiv1.style.display = 'none';
calculatorplannerdiv.style.display = 'block';
// Make all file input fields optional if hidden
uploadplannerinputs.forEach(function(input) {
input.required = false;
});
usercomments.required = false; // Make the field required if shown
myForm.target = "hidden_iframe";
myForm.action = "https://marbletops.co.uk/mail1.php";
}
}
function scrollToTop() {
// For modern browsers
document.documentElement.scrollTop = 0;
// For IE and older versions of some browsers
document.body.scrollTop = 0;
}
function calculateArea()
{ if (!validateForm()) {
alert("Please fill in all required fields.");
return; // Exit the function if validation fails
}
scrollToTop();
//selectedprices - dont edit this
var worktopprice = 0;
var splashbackprice = 0;
var upstandprice = 0;
var windowsillprice = 0;
var sinkcutoutprice = 0;
var tapcutoutprice = 0;
var recesseddraineprice = 0;
var drainergroovesprice = 0;
var notchcolumncutoutprice = 0;
var hobcutoutprice = 0;
var recessedhobcutoutprice = 0;
var socketcutoutprice = 0;
var template_fixingprice = 0;
var Name = document.querySelector('input[name="name"]').value;
var Postcode = document.querySelector('input[name="pcode"]').value;
var Email = document.querySelector('input[name="email"]').value;
var Phnumber = document.querySelector('input[name="phnumber"]').value;
var Howknow = document.querySelector('select[name="howknow"]').value;
var howtime = document.querySelector('select[name="howtime"]').value;
//var UpStand = parseFloat(document.getElementById("upstand").value);
//UpStand=UpStand ?UpStand:0;
// var Windowsill = parseFloat(document.getElementById("windowsill").value);
// Windowsill=Windowsill ?Windowsill:0;
if(document.querySelector('input[name="planner"]:checked').value==0){
document.getElementById("calculatorForm").style.display = "none";
document.getElementById("result").style.display = "block";
}
if(document.querySelector('input[name="planner"]:checked').value==1){
document.getElementById("calculatorForm").style.display = "block";
//alert("Thank you! Sending Successful.");
}
var SincCutOut = parseFloat(document.getElementById("Sinc-C").value);
SincCutOut=SincCutOut ?SincCutOut:0;
var SincCutOutqty;
if (SincCutOut ==""){
SincCutOutqty=0;
}
else{
SincCutOutqty=1;
}
var TapCutOut = parseFloat(document.getElementById("Tap-C").value);
TapCutOut=TapCutOut ?TapCutOut:0;
var TapCutOutqty;
if (TapCutOut ==""){
TapCutOutqty=0;
}
else{
TapCutOutqty=1;
}
var HobCutOut = parseFloat(document.getElementById("Hob-C").value);
HobCutOut=HobCutOut ?HobCutOut:0;
var HobCutOutqty;
if (HobCutOut ==""){
HobCutOutqty=0;
}
else{
HobCutOutqty=1;
}
var RecessedHob = parseFloat(document.getElementById("Recessed-H").value);
RecessedHob=RecessedHob ?RecessedHob:0;
var RecessedHobqty;
if (RecessedHob ==""){
RecessedHobqty=0;
}
else{
RecessedHobqty=1;
}
var DrainerGrooves = parseFloat(document.getElementById("Drainer-G").value);
DrainerGrooves=DrainerGrooves ?DrainerGrooves:0;
var DrainerGroovesqty;
if (DrainerGrooves ==""){
DrainerGroovesqty=0;
}
else{
DrainerGroovesqty=1;
}
var RecessedDrainer = parseFloat(document.getElementById("Recessed-D").value);
RecessedDrainer=RecessedDrainer ?RecessedDrainer:0;
var RecessedDrainerqty;
if (RecessedDrainer ==""){
RecessedDrainerqty=0;
}
else{
RecessedDrainerqty=1;
}
var SockedCutOut = parseFloat(document.getElementById("Socked-C").value);
SockedCutOut=SockedCutOut ?SockedCutOut:0;
var SockedCutOutqty;
if (SockedCutOut ==""){
SockedCutOutqty=0;
}
else{
SockedCutOutqty=1;
}
var ColumnCutOut = parseFloat(document.getElementById("Column-C").value);
ColumnCutOut=ColumnCutOut ?ColumnCutOut:0;
var ColumnCutOutqty;
if (ColumnCutOut ==""){
ColumnCutOutqty=0;
}
else{
ColumnCutOutqty=1;
}
var templateFixingValue = document.querySelector('input[name="TemplateFixing"]:checked');
templateFixingValue = templateFixingValue ? templateFixingValue.value : 0;
var tradersvalue = document.querySelector('input[name="trader"]:checked');
tradersvalue = tradersvalue ? tradersvalue.value : 0;
var companyname="";
if(tradersvalue==1){
companyname = document.getElementById("traderName").value;
companyname =`User Type: Trade