Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-05-13· OpenAIAi2 WildChat-4.8M (AI2)

check if the following code is correct: <!DOCTYPE html> <html lang="en"> <head>…

  1. User

    check if the following code is correct:

    <title>Steel Construction Cost Estimate</title> 
    
    <style> 
    
        .form-container { 
    
            max-width: 800px; 
    
            margin: auto; 
    
            padding: 10px; 
    
            border: 1px solid #ccc; 
    
            border-radius: 5px; 
    
        } 
    
    
    
        label, input, button, select { 
    
            display: block; 
    
            padding: 5px; 
    
            margin: 3px 0; 
    
        } 
    
    
    
    
    
        .dropdown-group { 
    
            margin-bottom: 5px; 
    
        } 
    
    
    
        .dropdown-group label { 
    
            display: block; /* Makes the label appear on a new line */ 
    
        } 
    
    
    
        button { 
    
            background-color: orangered; 
    
            color: white; 
    
            cursor: pointer; 
    
        } 
    
    
    
        label.required::after { 
    
            content: "*"; 
    
            color: orangered; 
    
            margin-left: 5px; 
    
        } 
    
    
    
        #estimatedCost { 
    
            font-weight: bold; 
    
            margin-top: 5px; 
    
        } 
    
    
    
        .radio-group label { 
    
            display: inline-block; 
    
            margin-right: 10px; /* Adjust the margin between radio buttons */ 
    
        } 
    
    
    
        .radio-group input[type="radio"] { 
    
            display: inline-block; 
    
            margin-right: 5px; /* Adjust the margin between radio buttons */ 
    
        } 
    
    
    
    </style> 
    
    <div class="form-container"> 
    
        <form id="fd88d2c" onsubmit="return calculateCost()"> 
    
            <fieldset> 
    
            <label for="name-764" class="required">Name:</label> 
    
            [text* name-764 id:name-764] 
    
             
    
            <label for="email-254" class="required">Email:</label> 
    
            [email* email-254 id:email-254] 
    
            
    
            <label for="tel-784" class="required">Telephone Number:</label> 
    
            [tel* tel-784 id:tel-784]           
    
        </fieldset> 
    
    
    
        <div class="radio-group"> 
    
            <label>Select Material:</label> 
    
            <label><input type="radio" name="material" value="chromadek" checked> Chromadek</label> 
    
            <label><input type="radio" name="material" value="galvanized"> Galvanized</label> 
    
        </div> 
    
    
    
        <div class="dropdown-group"> 
    
            <label for="lengthInput">Enter Length (in meters):</label> 
    
            <input type="number" id="lengthInput" name="length" min="5" max="100" oninput="checkFormValidity()"> 
    
        </div> 
    
    
    
        <div class="dropdown-group"> 
    
            <label for="widthDropdown">Select Width (in meters):</label> 
    
            <select id="widthDropdown" name="width" onchange="checkFormValidity()"> 
    
                <option value="">Select Width</option> 
    
                <option value="40">40m</option> 
    
                <option value="35">35m</option> 
    
                <option value="30">30m</option> 
    
                <option value="25">25m</option> 
    
                <option value="20">20m</option> 
    
                <option value="18">18m</option> 
    
                <option value="15">15m</option> 
    
                <option value="12">12m</option> 
    
            </select> 
    
        </div> 
    
    
    
        <div class="dropdown-group"> 
    
            <label for="sourceDropdown">Where did you hear about us?</label> 
    
            <select id="sourceDropdown" name="source" onchange="checkFormValidity()"> 
    
                <option value="">Select Source</option> 
    
                <option value="website">Website</option> 
    
                <option value="referral">Referral from someone</option> 
    
                <option value="onsite">Saw us on site</option> 
    
                <option value="linkedin">LinkedIn</option> 
    
                <option value="facebook">Facebook</option> 
    
                <option value="instagram">Instagram</option> 
    
                <option value="vehicle">Vehicle branding</option> 
    
                <option value="other">Other</option> 
    
            </select> 
    
        </div> 
    
            <button type="submit" id="calculateButton" onclick="calculateCost()">Calculate Cost</button> 
    
            <input type="hidden" id="hiddenCost" name="hiddenCost" value=""> 
    
        </form> 
    
        <div id="estimatedCost"></div> 
    
    </div> 
    
    
    
    <script> 
    
       // Function to get the price for Chromadek material based on width and length 
    

    function getPriceChromadek(width, length) {

    switch (width) { 
    
        case 40: 
    
            switch (length) { 
    
                case 5: return 218200; 
    
                case 10: return 436400; 
    
                case 15: return 654600; 
    
                case 20: return 872800; 
    
                case 25: return 1057000; 
    
                case 30: return 1268400; 
    
                case 35: return 1425200; 
    
                case 40: return 1628800; 
    
                case 45: return 1792800; 
    
                case 50: return 1992000; 
    
                case 55: return 2162600; 
    
                case 60: return 2359200; 
    
                case 65: return 2529800; 
    
                case 70: return 2724400; 
    
                case 75: return 2898000; 
    
                case 80: return 3091200; 
    
                case 85: return 3267400; 
    
                case 90: return 3459600; 
    
                case 95: return 3613800; 
    
                case 100: return 3804000; 
    
            } 
    
            break; 
    
        case 35: 
    
            switch (length) { 
    
                case 5: return 210175; 
    
                case 10: return 420350; 
    
                case 15: return 630525; 
    
                case 20: return 840700; 
    
                case 25: return 1021125; 
    
                case 30: return 1225350; 
    
                case 35: return 1382575; 
    
                case 40: return 1580100; 
    
                case 45: return 1738800; 
    
                case 50: return 1932000; 
    
                case 55: return 2097750; 
    
                case 60: return 2289000; 
    
                case 65: return 2456275; 
    
                case 70: return 2645450; 
    
                case 75: return 2817125; 
    
                case 80: return 3004400; 
    
                case 85: return 3178800; 
    
                case 90: return 3365200; 
    
                case 95: return 3539800; 
    
                case 100: return 3724000; 
    
            } 
    
            break; 
    
        case 30: 
    
            switch (length) { 
    
                case 5: return 160200; 
    
                case 10: return 320400; 
    
                case 15: return 480600; 
    
                case 20: return 640800; 
    
                case 25: return 771750; 
    
                case 30: return 926100; 
    
                case 35: return 1034250; 
    
                case 40: return 1182000; 
    
                case 45: return 1296000; 
    
                case 50: return 1440000; 
    
                case 55: return 1559250; 
    
                case 60: return 1701000; 
    
                case 65: return 1821300; 
    
                case 70: return 1961400; 
    
                case 75: return 2083500; 
    
                case 80: return 2222400; 
    
                case 85: return 2346000; 
    
                case 90: return 2484000; 
    
                case 95: return 2609250; 
    
                case 100: return 2745000; 
    
            } 
    
            break; 
    
        case 25: 
    
            switch (length) { 
    
                case 5: return 127750; 
    
                case 10: return 255500; 
    
                case 15: return 383250; 
    
                case 20: return 511000; 
    
                case 25: return 615000; 
    
                case 30: return 738000; 
    
                case 35: return 823250; 
    
                case 40: return 942000; 
    
                case 45: return 1031625; 
    
                case 50: return 1146250; 
    
                case 55: return 1240250; 
    
                case 60: return 1353000; 
    
                case 65: return 1449500; 
    
                case 70: return 1561000; 
    
                case 75: return 1657500; 
    
                case 80: return 1768000; 
    
                case 85: return 1865750; 
    
                case 90: return 19755000; 
    
                case 95: return 2075750; 
    
                case 100: return 2185000; 
    
            } 
    
            break; 
    
        case 20: 
    
            switch (length) { 
    
                case 5: return 94400; 
    
                case 10: return 188800; 
    
                case 15: return 283200; 
    
                case 20: return 377600; 
    
                case 25: return 456500; 
    
                case 30: return 547800; 
    
                case 35: return 613900; 
    
                case 40: return 701600; 
    
                case 45: return 771300; 
    
                case 50: return 857000; 
    
                case 55: return 929500; 
    
                case 60: return 1014000; 
    
                case 65: return 1086800; 
    
                case 70: return 1170400; 
    
                case 75: return 1245000; 
    
                case 80: return 1328000; 
    
                case 85: return 1402500; 
    
                case 90: return 1485000; 
    
                case 95: return 1559900; 
    
                case 100: return 1642000; 
    
            } 
    
            break; 
    

    case 18:

            switch (length) { 
    
                case 5: return 78390; 
    
                case 10: return 156780; 
    
                case 15: return 235170; 
    
                case 20: return 313560; 
    
                case 25: return 379800; 
    
                case 30: return 455760; 
    
                case 35: return 512190; 
    
                case 40: return 585360; 
    
                case 45: return 644760; 
    
                case 50: return 716400; 
    
                case 55: return 778140; 
    
                case 60: return 848880; 
    
                case 65: return 912330; 
    
                case 70: return 982740; 
    
                case 75: return 1044550; 
    
                case 80: return 1114320; 
    
                case 85: return 1175970; 
    
                case 90: return 1245780; 
    
                case 95: return 1309860; 
    
                case 100: return 1378800; 
    
            } 
    
            break; 
    
        case 15: 
    
            switch (length) { 
    
                case 5: return 59925; 
    
                case 10: return 119850; 
    
                case 15: return 179775; 
    
                case 20: return 239700; 
    
                case 25: return 291750; 
    
                case 30: return 350100; 
    
                case 35: return 395850; 
    
                case 40: return 452400; 
    
                case 45: return 500175; 
    
                case 50: return 555750; 
    
                case 55: return 604725; 
    
                case 60: return 659700; 
    
                case 65: return 708825; 
    
                case 70: return 763350; 
    
                case 75: return 813375; 
    
                case 80: return 867600; 
    
                case 85: return 918000; 
    
                case 90: return 972000; 
    
                case 95: return 1021725; 
    
                case 100: return 1075500; 
    
            } 
    
            break; 
    
        case 12: 
    
            switch (length) { 
    
                case 5: return 60600; 
    
                case 10: return 121200; 
    
                case 15: return 181800; 
    
                case 20: return 242400; 
    
                case 25: return 294900; 
    
                case 30: return 353880; 
    
                case 35: return 399840; 
    
                case 40: return 456960; 
    
                case 45: return 514080; 
    
                case 50: return 561000; 
    
                case 55: return 609840; 
    
                case 60: return 665280; 
    
                case 65: return 715260; 
    
                case 70: return 770280; 
    
                case 75: return 819900; 
    
                case 80: return 874560; 
    
                case 85: return 925140; 
    
                case 90: return 97950; 
    
                case 95: return 1029420; 
    
                case 100: return 1083600; 
    
            } 
    
            break; 
    
        default: 
    
            return 0; // default return if no matching case 
    
    } 
    

    }

        // Function to get the price for Galvanized material based on width and length 
    

    function getPriceGalvanized(width, length) {

    switch (width) { 
    
        case 40: 
    
            switch (length) { 
    
                case 5: return 205800; 
    
                case 10: return 411600; 
    
                case 15: return 617400; 
    
                case 20: return 823200; 
    
                case 25: return 996000; 
    
                case 30: return 1194000; 
    
                case 35: return 1339800; 
    
                case 40: return 1531200; 
    
                case 45: return 1683000; 
    
                case 50: return 1870000; 
    
                case 55: return 2026400; 
    
                case 60: return 2217600; 
    
                case 65: return 2371200; 
    
                case 70: return 2548800; 
    
                case 75: return 2715000; 
    
                case 80: return 2896000; 
    
                case 85: return 3060000; 
    
                case 90: return 3240000; 
    
                case 95: return 3404800; 
    
                case 100: return 3584000; 
    
            } 
    
            break; 
    
        case 35: 
    
            switch (length) { 
    
                case 5: return 199500; 
    
                case 10: return 399000; 
    
                case 15: return 598500; 
    
                case 20: return 798000; 
    
                case 25: return 967375; 
    
                case 30: return 1157000; 
    
                case 35: return 1291250; 
    
                case 40: return 1493200; 
    
                case 45: return 1639800; 
    
                case 50: return 1827000; 
    
                case 55: return 1997250; 
    
                case 60: return 2175000; 
    
                case 65: return 2318600; 
    
                case 70: return 2493700; 
    
                case 75: return 2662425; 
    
                case 80: return 2835800; 
    
                case 85: return 2968800; 
    
                case 90: return 3171600; 
    
                case 95: return 3329700; 
    
                case 100: return 3510000; 
    
            } 
    
            break; 
    
        case 30: 
    
            switch (length) { 
    
                case 5: return 150900; 
    
                case 10: return 301800; 
    
                case 15: return 452700; 
    
                case 20: return 603600; 
    
                case 25: return 726000; 
    
                case 30: return 870000; 
    
                case 35: return 971250; 
    
                case 40: return 1110000; 
    
                case 45: return 1215000; 
    
                case 50: return 1350000; 
    
                case 55: return 1462500; 
    
                case 60: return 1620000; 
    
                case 65: return 1701000; 
    
                case 70: return 1834800; 
    
                case 75: return 1946100; 
    
                case 80: return 2078400; 
    
                case 85: return 2202300; 
    
                case 90: return 2322000; 
    
                case 95: return 2441250; 
    
                case 100: return 2565000; 
    
            } 
    
            break; 
    
        case 25: 
    
            switch (length) { 
    
                case 5: return 120000; 
    
                case 10: return 240000; 
    
                case 15: return 360000; 
    
                case 20: return 480000; 
    
                case 25: return 575000; 
    
                case 30: return 690000; 
    
                case 35: return 770000; 
    
                case 40: return 880000; 
    
                case 45: return 963000; 
    
                case 50: return 1071000; 
    
                case 55: return 1151125; 
    
                case 60: return 1261500; 
    
                case 65: return 1352375; 
    
                case 70: return 1456500; 
    
                case 75: return 1543125; 
    
                case 80: return 1646000; 
    
                case 85: return 1726875; 
    
                case 90: return 1832250; 
    
                case 95: return 1923375; 
    
                case 100: return 2032500; 
    
            } 
    
            break; 
    
        case 20: 
    
            switch (length) { 
    
                case 5: return 88200; 
    
                case 10: return 176400; 
    
                case 15: return 264600; 
    
                case 20: return 352800; 
    
                case 25: return 425500; 
    
                case 30: return 510600; 
    
                case 35: return 571200; 
    
                case 40: return 652800; 
    
                case 45: return 716400; 
    
                case 50: return 796000; 
    
                case 55: return 861300; 
    
                case 60: return 939600; 
    
                case 65: return 1007000; 
    
                case 70: return 1085000; 
    
                case 75: return 1152000; 
    
                case 80: return 1228800; 
    
                case 85: return 1292400; 
    
                case 90: return 1372800; 
    
                case 95: return 1444000; 
    
                case 100: return 1520000; 
    
            } 
    
            break; 
    
        case 18: 
    
            switch (length) { 
    
                case 5: return 72630; 
    
                case 10: return 145260; 
    
                case 15: return 217890; 
    
                case 20: return 290520; 
    
                case 25: return 351450; 
    
                case 30: return 421860; 
    
                case 35: return 473670; 
    
                case 40: return 540720; 
    
                case 45: return 594000; 
    
                case 50: return 661200; 
    
                case 55: return 715920; 
    
                case 60: return 782880; 
    
                case 65: return 837480; 
    
                case 70: return 900720; 
    
                case 75: return 959100; 
    
                case 80: return 1025280; 
    
                case 85: return 1080510; 
    
                case 90: return 1145580; 
    
                case 95: return 1202280; 
    
                case 100: return 1269600; 
    
            } 
    
            break; 
    
        case 15: 
    
            switch (length) { 
    
                case 5: return 55050; 
    
                case 10: return 110100; 
    
                case 15: return 165150; 
    
                case 20: return 220200; 
    
                case 25: return 267375; 
    
                case 30: return 320850; 
    
                case 35: return 362250; 
    
                case 40: return 414000; 
    
                case 45: return 457650; 
    
                case 50: return 508500; 
    
                case 55: return 553500; 
    
                case 60: return 603000; 
    
                case 65: return 643800; 
    
                case 70: return 696600; 
    
                case 75: return 742500; 
    
                case 80: return 793200; 
    
                case 85: return 831450; 
    
                case 90: return 885660; 
    
                case 95: return 926550; 
    
                case 100: return 981000; 
    
            } 
    
            break; 
    
        case 12: 
    
            switch (length) { 
    
                case 5: return 55800; 
    
                case 10: return 111600; 
    
                case 15: return 167400; 
    
                case 20: return 223200; 
    
                case 25: return 270900; 
    
                case 30: return 325080; 
    
                case 35: return 366780; 
    
                case 40: return 419040; 
    
                case 45: return 462480; 
    
                case 50: return 513600; 
    
                case 55: return 556200; 
    
                case 60: return 607800; 
    
                case 65: return 653100; 
    
                case 70: return 704520; 
    
                case 75: return 748800; 
    
                case 80: return 798720; 
    
                case 85: return 846720; 
    
                case 90: return 894240; 
    
                case 95: return 940500; 
    
                case 100: return 990000; 
    
            } 
    
            break; 
    
        default: 
    
            return 0; // default return if no matching case 
    
    } 
    

    }

        // Function to calculate the total price based on material, width, and length 
    
        function calculateTotalPrice(material, width, length) { 
    
            if (material === 'Chromadek') { 
    
                return getPriceChromadek(width, length); 
    
            } else if (material === 'Galvanized') { 
    
                return getPriceGalvanized(width, length); 
    
            } else { 
    
                return 0; // default return if no matching material 
    
            } 
    
        } 
    
    
    
        function updateCost() { 
    
            var material = document.querySelector('input[name="material"]:checked').value; 
    
            var length = parseInt(document.getElementById("lengthDropdown").value); 
    
            var width = parseInt(document.getElementById("widthDropdown").value); 
    
            var cost = calculateTotalPrice(material, width, length); 
    
    
    
            document.getElementById("hiddenCost").value = cost; 
    
            document.getElementById("estimatedCost").innerText = "Estimated Cost: R " + cost.toLocaleString(); 
    
        } 
    
    
    
        function calculateCost() { 
    
            updateCost(); 
    
            return false; // Prevent form submission for demo 
    
        } 
    
    
    
        // Add event listener to material radio buttons 
    
        document.querySelectorAll('input[name="material"]').forEach(function(radio) { 
    
            radio.addEventListener('change', updateCost); 
    
        }); 
    
    </script> 
    
  2. Assistant

    The code you have presented is largely correct, but it contains a few issues and inconsistencies that need to be addressed for it to work properly.

    Issues:

    1. Input Elements for Name, Email, and Telephone: The placeholders [text* name-764 id:name-764], [email* email-254 id:email-254], and [tel* tel-784 id:tel-784] appear to use the syntax from a form builder plugin (e.g., Contact Form 7 for WordPress). These need to be replaced with standard HTML input tags.

    2. JavaScript Logic Errors:

      • In the calculateTotalPrice function, material values should be in lowercase to match the radio button values.
      • The updateCost function references a non-existent element lengthDropdown, it should be lengthInput.
    3. Syntax Error:

      • There's a typo in estimate_ cost inside the updateCost function, replace it with estimatedCost.
    4. Improving Readability:

      • You should reformat your code for better readability. This involves fixing the indentation and structure.

    Here's a corrected and improved version of your code:

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
    
        <title>Steel Construction Cost Estimate</title>
    
        <style>
            .form-container {
                max-width: 800px;
                margin: auto;
                padding: 10px;
                border: 1px solid #ccc;
                border-radius: 5px;
            }
    
            label,
            input,
            button,
            select {
                display: block;
                padding: 5px;
                margin: 3px 0;
            }
    
            .dropdown-group {
                margin-bottom: 5px;
            }
    
            .dropdown-group label {
                display: block;
                /* Makes the label appear on a new line */
            }
    
            button {
                background-color: orangered;
                color: white;
                cursor: pointer;
            }
    
            label.required::after {
                content: "*";
                color: orangered;
                margin-left: 5px;
            }
    
            #estimatedCost {
                font-weight: bold;
                margin-top: 5px;
            }
    
            .radio-group label {
                display: inline-block;
                margin-right: 10px;
                /* Adjust the margin between radio buttons */
            }
    
            .radio-group input[type="radio"] {
                display: inline-block;
                margin-right: 5px;
                /* Adjust the margin between radio buttons */
            }
        </style>
    
    </head>
    
    <body>
        <div class="form-container">
            <form id="fd88d2c" onsubmit="return calculateCost()">
                <fieldset>
                    <label for="name-764" class="required">Name:</label>
                    <input type="text" id="name-764" name="name-764" required>
    
                    <label for="email-254" class="required">Email:</label>
                    <input type="email" id="email-254" name="email-254" required>
    
                    <label for="tel-784" class="required">Telephone Number:</label>
                    <input type="tel" id="tel-784" name="tel-784" required>
                </fieldset>
    
                <div class="radio-group">
                    <label>Select Material:</label>
                    <label><input type="radio" name="material" value="chromadek" checked> Chromadek</label>
                    <label><input type="radio" name="material" value="galvanized"> Galvanized</label>
                </div>
    
                <div class="dropdown-group">
                    <label for="lengthInput">Enter Length (in meters):</label>
                    <input type="number" id="lengthInput" name="length" min="5" max="100" oninput="checkFormValidity()">
                </div>
    
                <div class="dropdown-group">
                    <label for="widthDropdown">Select Width (in meters):</label>
                    <select id="widthDropdown" name="width" onchange="checkFormValidity()">
                        <option value="">Select Width</option>
                        <option value="40">40m</option>
                        <option value="35">35m</option>
                        <option value="30">30m</option>
                        <option value="25">25m</option>
                        <option value="20">20m</option>
                        <option value="18">18m</option>
                        <option value="15">15m</option>
                        <option value="12">12m</option>
                    </select>
                </div>
    
                <div class="dropdown-group">
                    <label for="sourceDropdown">Where did you hear about us?</label>
                    <select id="sourceDropdown" name="source" onchange="checkFormValidity()">
                        <option value="">Select Source</option>
                        <option value="website">Website</option>
                        <option value="referral">Referral from someone</option>
                        <option value="onsite">Saw us on site</option>
                        <option value="linkedin">LinkedIn</option>
                        <option value="facebook">Facebook</option>
                        <option value="instagram">Instagram</option>
                        <option value="vehicle">Vehicle branding</option>
                        <option value="other">Other</option>
                    </select>
                </div>
    
                <button type="submit" id="calculateButton">Calculate Cost</button>
                <input type="hidden" id="hiddenCost" name="hiddenCost" value="">
            </form>
            <div id="estimatedCost"></div>
        </div>
    
        <script>
            // Function to get the price for Chromadek material based on width and length
            function getPriceChromadek(width, length) {
                const prices = {
                    40: { 5: 218200, 10: 436400, 15: 654600, 20: 872800, 25: 1057000, 30: 1268400, 35: 1425200, 40: 1628800, 45: 1792800, 50: 1992000, 55: 2162600, 60: 2359200, 65: 2529800, 70: 2724400, 75: 2898000, 80: 3091200, 85: 3267400, 90: 3459600, 95: 3613800, 100: 3804000 },
                    35: { 5: 210175, 10: 420350, 15: 630525, 20: 840700, 25: 1021125, 30: 1225350, 35: 1382575, 40: 1580100, 45: 1738800, 50: 1932000, 55: 2097750, 60: 2289000, 65: 2456275, 70: 2645450, 75: 2817125, 80: 3004400, 85: 3178800, 90: 3365200, 95: 3539800, 100: 3724000 },
                    30: { 5: 160200, 10: 320400, 15: 480600, 20: 640800, 25: 771750, 30: 926100, 35: 1034250, 40: 1182000, 45: 1296000, 50: 1440000, 55: 1559250, 60: 1701000, 65: 1821300, 70: 1961400, 75: 2083500, 80: 2222400, 85: 2346000, 90: 2484000, 95: 2609250, 100: 2745000 },
                    25: { 5: 127750, 10: 255500, 15: 383250, 20: 511000, 25: 615000, 30: 738000, 35: 823250, 40: 942000, 45: 1031625, 50: 1146250, 55: 1240250, 60: 1353000, 65: 1449500, 70: 1561000, 75: 1657500, 80: 1768000, 85: 1865750, 90: 19755000, 95: 2075750, 100: 2185000 },
                    20: { 5: 94400, 10: 188800, 15: 283200, 20: 377600, 25: 456500, 30: 547800, 35: 613900, 40: 701600, 45: 771300, 50: 857000, 55: 929500, 60: 1014000, 65: 1086800, 70: 1170400, 75: 1245000, 80: 1328000, 85: 1402500, 90: 1485000, 95: 1559900, 100: 1642000 },
                    18: { 5: 78390, 10: 156780, 15: 235170, 20: 313560, 25: 379800, 30: 455760, 35: 512190, 40: 585360, 45: 644760, 50: 716400, 55: 778140, 60: 848880, 65: 912330, 70: 982740, 75: 1044550, 80: 1114320, 85: 1175970, 90: 1245780, 95: 1309860, 100: 1378800 },
                    15: { 5: 59925, 10: 119850, 15: 179775, 20: 239700, 25: 291750, 30: 350100, 35: 395850, 40: 452400, 45: 500175, 50: 555750, 55: 604725, 60: 659700, 65: 708825, 70: 763350, 75: 813375, 80: 867600, 85: 918000, 90: 972000, 95: 1021725, 100: 1075500 },
                    12: { 5: 60600, 10: 121200, 15: 181800, 20: 242400, 25: 294900, 30: 353880, 35: 399840, 40: 456960, 45: 514080, 50: 561000, 55: 609840, 60: 665280, 65: 715260, 70: 770280, 75: 819900, 80: 874560, 85: 925140, 90: 97950, 95: 1029420, 100: 1083600 }
                };
    
                return prices[width] && prices[width][length] ? prices[width][length] : 0;
            }
    
            // Function to get the price for Galvanized material based on width and length
            function getPriceGalvanized(width, length) {
                const prices = {
                    40: { 5: 205800, 10: 411600, 15: 617400, 20: 823200, 25: 996000, 30: 1194000, 35: 1339800, 40: 1531200, 45: 1683000, 50: 1870000, 55: 2026400, 60: 2217600, 65: 2371200, 70: 2548800, 75: 2715000, 80: 2896000, 85: 3060000, 90: 3240000, 95: 3404800, 100: 3584000 },
                    35: { 5: 199500, 10: 399000, 15: 598500, 20: 798000, 25: 967375, 30: 1157000, 35: 1291250, 40: 1493200, 45: 1639800, 50: 1827000, 55: 1997250, 60: 2175000, 65: 2318600, 70: 2493700, 75: 2662425, 80: 2835800, 85: 2968800, 90: 3171600, 95: 3329700, 100: 3510000 },
                    30: { 5: 150900, 10: 301800, 15: 452700, 20: 603600, 25: 726000, 30: 870000, 35: 971250, 40: 1110000, 45: 1215000, 50: 1350000, 55: 1462500, 60: 1620000, 65: 1701000, 70: 1834800, 75: 1946100, 80: 2078400, 85: 2202300, 90: 2322000, 95: 2441250, 100: 2565000 },
                    25: { 5: 120000, 10: 240000, 15: 360000, 20: 480000, 25: 575000, 30: 690000, 35: 770000, 40: 880000, 45: 963000, 50: 1071000, 55: 1151125, 60: 1261500, 65: 1352375, 70: 1456500, 75: 1543125, 80: 1646000, 85: 1726875, 90: 1832250, 95: 1923375, 100: 2032500 },
                    20: { 5: 88200, 10: 176400, 15: 264600, 20: 352800, 25: 425500, 30: 510600, 35: 571200, 40: 652800, 45: 716400, 50: 796000, 55: 861300, 60: 939600, 65: 1007000, 70: 1085000, 75: 1152000, 80: 1228800, 85: 1292400, 90: 1372800, 95: 1444000, 100: 1520000 },
                    18: { 5: 72630, 10: 145260, 15: 217890, 20: 290520, 25: 351450, 30: 421860, 35: 473670, 40: 540720, 45: 594000, 50: 661200, 55: 715920, 60: 782880, 65: 837480, 70: 900720, 75: 959100, 80: 1025280, 85: 1080510, 90: 1145580, 95: 1202280, 100: 1269600 },
                    15: { 5: 55050, 10: 110100, 15: 165150, 20: 220200, 25: 267375, 30: 320850, 35: 362250, 40: 414000, 45: 457650, 50: 508500, 55: 553500, 60: 603000, 65: 643800, 70: 696600, 75: 742500, 80: 793200, 85: 831450, 90: 885660, 95: 926550, 100: 981000 },
                    12: { 5: 55800, 10: 111600, 15: 167400, 20: 223200, 25: 270900, 30: 325080, 35: 366780, 40: 419040, 45: 462480, 50: 513600, 55: 556200, 60: 607800, 65: 653100, 70: 704520, 75: 748800, 80: 798720, 85: 846720, 90: 894240, 95: 940500, 100: 990000 }
                };
    
                return prices[width] && prices[width][length] ? prices[width][length] : 0;
            }
    
            // Function to calculate the total price based on material, width, and length
            function calculateTotalPrice(material, width, length) {
                if (material === 'chromadek') {
                    return getPriceChromadek(width, length);
                } else if (material === 'galvanized') {
                    return getPriceGalvanized(width, length);
                } else {
                    return 0; // default return if no matching material
                }
            }
    
            function updateCost() {
                var material = document.querySelector('input[name="material"]:checked').value;
                var length = parseInt(document.getElementById("lengthInput").value);
                var width = parseInt(document.getElementById("widthDropdown").value);
                var cost = calculateTotalPrice(material, width, length);
    
                document.getElementById("hiddenCost").value = cost;
                document.getElementById("estimatedCost").innerText = "Estimated Cost: R " + cost.toLocaleString();
            }
    
            function calculateCost() {
                updateCost();
                return false; // Prevent form submission for demo
            }
    
            // Add event listener to material radio buttons
            document.querySelectorAll('input[name="material"]').forEach(function (radio) {
                radio.addEventListener('change', updateCost);
            });
        </script>
    </body>
    
    </html>
    

    Improvements made:

    1. Replaced placeholders [text* name-764 id:name-764],