please help me to have a javascript for my buttons: <button type="submit"  value="4x6">Shipping Label 4x6</button>
<button type="submit"  value="8.5x11">Letter (8.5x11)</button>
<button type="submit"  value="pole">Pole Label (8.5x11)</button>
<button onclick="printLabel()">Print</button>
<button onclick="goBack()">Go Back</button>  here is my whole code:   
    document.getElementById('labelSizeConfirmBtn').onclick = function() {
        var selectedSize = document.querySelector('input[name="labelSize"]:checked').value;


// Handle generate label request
if (isset($_GET['generate_label']) && isset($_GET['orderNo'])) {
    $orderNo = $_GET['orderNo'];
    $order = null;

    // Find the order details
    foreach ($branchOrders as $o) {
        if ($o["orderno"] == $orderNo) {
            $order = $o;
            break;
        }
    }

    if ($order) {
        $companyName = $order["comp"];
        $customer = fetchCustomerDetailsByCompanyName($companyName, $conn);

        if ($customer) {
            $customer_name = $customer["Display Name"] ?: $customer["Name"];

                 // Initialize sender details
            $sender_name = "";
            $sender_phone = "";
            $sender_address = "";
            $sender_city = "";
            $sender_state = "";
            $sender_zip = "";

            // Set sender details based on branch
            if ($order['branch'] === 'ST') {
                $sender_name = "CENTRAL TENT";
                $sender_phone = "800-997-8368";
                $sender_address = "5911 HAMBLEN DR.";
                $sender_city = "HUMBLE";
                $sender_state = "TX";
                $sender_zip = "77396";
            } elseif ($order['branch'] === 'AT') {
                $sender_name = "CENTRAL TENT";
                $sender_phone = "800-997-8368";
                $sender_address = "889 INDUSTRIAL BLVD";
                $sender_city = "RINGGOLD";
                $sender_state = "GA";
                $sender_zip = "30736";
            }


            // Recipient information from the database
            $recipient_name = htmlspecialchars($customer_name ?? '');
            $recipient_address = htmlspecialchars(($customer["Street"] ?? '') . (isset($customer["Street2"]) ? ' ' . ($customer["Street2"] ?? '') : ''));
            $recipient_city = htmlspecialchars($customer["City"] ?? '');
            $recipient_state = htmlspecialchars($customer["State"] ?? '');
            $recipient_zip = htmlspecialchars($customer["Zip"] ?? '');
            $recipient_phone = htmlspecialchars($customer["Phone"] ?? '');

            // Special instructions (if available)
            $special_instructions = htmlspecialchars($customer["Additional info"] ?? '');

            // Initialize default values for width and height
            $width = '4in';
            $height = '6in';

            // Handle predefined and custom sizes
            if (isset($_GET['size'])) {
                switch ($_GET['size']) {
                    case '8.5x11':
                        $width = '8.5in';
                        $height = '11in';
                        break;
                    case 'custom':
                        if (isset($_GET['custom_width']) && isset($_GET['custom_height']) && isset($_GET['unit'])) {
                            $custom_width = trim($_GET['custom_width']);
                            $custom_height = trim($_GET['custom_height']);
                            $unit = trim($_GET['unit']);
                            if (is_numeric($custom_width) && is_numeric($custom_height) && in_array($unit, ['in', 'cm', 'mm'])) {
                                $width = $custom_width . $unit;
                                $height = $custom_height . $unit;
                            }
                        }
                        break;
                    case 'pallet':
                        echo '<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Pallet Label Layout</title>
    <style>
       
    </style>
</head>
<body>
    <div style="text-align: center; margin-top: 0px;" class="no-print">
        <button type="submit"  value="4x6">Shipping Label 4x6</button>
        <button type="submit"  value="8.5x11">Letter (8.5x11)</button>
        <button type="submit"  value="pole">Pole Label (8.5x11)</button>
        <button onclick="printLabel()">Print</button>
        <button onclick="goBack()">Go Back</button>
    </div>
    <div class="page">
        <div class="label-container label-editable">
            <div class="logo">
                <img src="assets/images/logo.png" alt="Central Tent">
            </div>
            <div class="header">
                <div class="sender-info">
                    ' . htmlspecialchars($sender_name) . '<br>
                    ' . htmlspecialchars($sender_address) . '<br>
                    ' . htmlspecialchars($sender_city) . ' ' . htmlspecialchars($sender_state) . ' ' . htmlspecialchars($sender_zip) . '<br>
                    ' . htmlspecialchars($sender_phone) . '
                </div>
                <div class="shipment-details">
                    <p><label>Ord#:</label> <input type="text" name="order_number" value="' . htmlspecialchars($order["orderno"]) . '"></p>
                    <p><label>Via:</label> <input type="text" name="ship_via" value="' . htmlspecialchars($order["shipvia"]) . '"></p>
                    <p><label>Sales:</label> <input type="text" name="sales" value="' . htmlspecialchars($order["salesp"]) . '"></p>
                    <p><label>Cust#:</label> <input type="text" name="customer_phone" value="' . htmlspecialchars($order["telnum"]) . '"></p>
                </div>
            </div>
            <div class="recipient-info">
                <div style="text-align: left; margin-left: 10px; font-size: 12pt;">Ship To:</div>
                <textarea name="recipient_details">' . htmlspecialchars($recipient_name) . "\n" . htmlspecialchars($recipient_address) . "\n" . htmlspecialchars($recipient_city) . ' ' . htmlspecialchars($recipient_state) . ' ' . htmlspecialchars($recipient_zip) . '</textarea>
            </div>
        </div>
    </div>
    <script>
        function printLabel() {
            window.print();
        }

        function goBack() {
            window.history.back();
        }
        document.addEventListener("DOMContentLoaded", (event) => {
            const originalLabel = document.querySelector(".label-editable");
            const duplicateLabelsContainer = document.querySelector(".page");
            for (let i = 0; i < 1; i++) {
                const duplicateLabel = originalLabel.cloneNode(true);
                duplicateLabelsContainer.appendChild(duplicateLabel);
            }
        });
    </script>
</body>
</html>
';
                        exit();
                    case 'pole':
                        echo '
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Label Layout</title>
    <style>
     
    </style>
</head>
<body>
    <div style="text-align: center; margin-top: 0px;" class="no-print">
        <button onclick="printLabel()">Print</button>
        <button onclick="goBack()">Go Back</button>
    </div>
    <div class="page">
        <div class="label-container label-editable">
            <div class="logo">
                <img src="assets/images/logo.png" alt="Central Tent">
            </div>
            <div class="header">
                <div class="sender-info">
                    ' . htmlspecialchars($sender_name) . '<br>
                    ' . htmlspecialchars($sender_address) . '<br>
                    ' . htmlspecialchars($sender_city) . ' ' . htmlspecialchars($sender_state) . ' ' . htmlspecialchars($sender_zip) . '<br>
                    ' . htmlspecialchars($sender_phone) . '
                </div>
<div class="shipment-details">
    <p><label>Ord#:</label> <input type="text" name="order_number" value="' . htmlspecialchars($order["orderno"]) . '"></p>
    <p><label>Via:</label> <input type="text" name="ship_via" value="' . htmlspecialchars($order["shipvia"]) . '"></p>
    <p><label>Sales:</label> <input type="text" name="sales" value="' . htmlspecialchars($order["salesp"]) . '"></p>
    <p><label>Cust#:</label> <input type="text" name="customer_phone" value="' . htmlspecialchars($order["telnum"]) . '"></p>
</div>
            </div>
            <div class="recipient-info">
                <div style="text-align: left; margin-left: 10px; font-size: 10pt;">Ship To:</div>
                <textarea name="recipient_details">' . htmlspecialchars($recipient_name) . "\n" . htmlspecialchars($recipient_address) . "\n" . htmlspecialchars($recipient_city) . ' ' . htmlspecialchars($recipient_state) . ' ' . htmlspecialchars($recipient_zip) . '</textarea>
            </div>
        </div>
    </div>
    <script>
        function printLabel() {
            window.print();
        }

        function goBack() {
            window.history.back();
        }

        document.addEventListener("DOMContentLoaded", (event) => {
            const originalLabel = document.querySelector(".label-editable");
            const duplicateLabelsContainer = document.querySelector(".page");

            for (let i = 0; i < 7; i++) {
                const duplicateLabel = originalLabel.cloneNode(true);
                duplicateLabelsContainer.appendChild(duplicateLabel);
            }
        });
    </script>
</body>
</html>
';
                        exit();
                }
            }

            // Create HTML for the shipping label
            $html = '
          <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Label Layout</title>
    <style>
         
    </style>
</head>
<body>
    <div style="text-align: center; margin-top: 0px;" class="no-print">
        <button onclick="printLabel()">Print</button>
        <button onclick="goBack()">Go Back</button>
    </div>
    <div class="container" id="printableArea">
        <div class="logo">
            <img src="assets/images/logo.png" alt="Your Logo" style="width: 100px; height: auto; margin-bottom: -10px;">
        </div>
        <div class="label-section sender-info">
            <div class="address">
                <p>' . htmlspecialchars($sender_name) . '<br>
                ' . htmlspecialchars($sender_address) . '<br>
                ' . htmlspecialchars($sender_city) . ' ' . htmlspecialchars($sender_state) . ' ' . htmlspecialchars($sender_zip) . '<br>
                ' . htmlspecialchars($sender_phone) . '</p>
            </div>
        </div>
        <div class="label-section recipient-info">
            <div class="section-title">Ship To:</div>
            <div class="address">
                <p><strong>' . htmlspecialchars($recipient_name) . '</strong><br>
                ' . htmlspecialchars($recipient_address) . '<br>
                ' . htmlspecialchars($recipient_city) . ' ' . htmlspecialchars($recipient_state) . ' ' . htmlspecialchars($recipient_zip) . '</p>
            </div>
        </div>
        <div class="label-section shipment-details">
            <div class="section-title">Shipment Details:</div>
            <div class="details">
                <p><strong>Order Number:</strong> <input type="text" name="order_number" value="' . htmlspecialchars($order["orderno"]) . '"></p>
                <p><strong>Weight:</strong> <input type="text" name="weight" value=""></p>
                <p><strong>Ship Via:</strong> <input type="text" name="ship_via" value="' . htmlspecialchars($order["shipvia"]) . '"></p>
                <p><strong>Shipping Date:</strong> <input type="text" name="shipping_date" value="' . htmlspecialchars($order["shipdate"]) . '"></p>
                <p><strong>Tracking Number:</strong> <input type="text" name="tracking_number" value=""></p>
                <p><strong>Customer#:</strong> <input type="text" name="customer_number" value="' . htmlspecialchars($order["telnum"]) . '"></p>
            </div>
        </div>
        <div class="label-section additional-info">
            <div class="info">
                <p>Special Instructions:</p>
                <textarea class="multiline-input" name="special_instructions">' . htmlspecialchars($special_instructions) . '</textarea></p>
            </div>
        </div>
    </div>
</body>
<script>
    function printLabel() {
        window.print();
    }

    function goBack() {
        window.history.back();
    }
</script>
</html>
';
            echo $html;
            exit();
        } else {
            echo '<script>alert("Customer details not found for the selected order.");</script>';
        }
    } else {
        echo '<script>alert("Order not found.");</script>';
    }
}