Google Apps Script
Exception: Malformed HTML content: <!DOCTYPE html> <html lang="th"> <head> <base target="_top"> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>ผู้ได้รับทุนการศึกษาบุตรสมาชิกประจำปี 2569</title> <!-- Tailwind CSS & Bootstrap & Fonts --> <script src="https://cdn.tailwindcss.com"></script> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap" rel="stylesheet"> <style> body { font-family: 'Sarabun', sans-serif; } .table { font-family: 'Sarabun', sans-serif; font-size: 1rem !important; } </style> </head> <body class="bg-gray-100 min-h-screen flex flex-col"> <!-- Header --> <header class="bg-[#1e3a8a] text-white shadow-md"> <div class="container mx-auto px-4 py-4 flex flex-col md:flex-row justify-between items-center"> <div class="flex items-center gap-4"> <div class="bg-white rounded-full p-2 text-[#1e3a8a]"> <svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /> </svg> </div> <div> <h1 class="text-xl font-bold">ผู้ได้รับทุนการศึกษาบุตรสมาชิกประจำปี 2569</h1> <p class="text-sm text-blue-200">สอ.กฝร. จำกัด</p> </div> </div> <!-- Counter --> <div class="mt-4 md:mt-0"> <a href="https://www.freecounterstat.com" title="free stat counter"> <img src="https://counter1.optistats.ovh/private/freecounterstat.php?c=9ls7uht49g42heuc914xlntgmcbpxuk3" border="0" alt="free stat counter" class="rounded opacity-80 hover:opacity-100 transition"> </a> </div> </div> </header> <!-- Main Content --> <main class="flex-grow flex justify-center p-4 mt-6"> <div class="bg-white rounded-xl shadow-lg w-full max-w-4xl p-6 md:p-8 border border-gray-200"> <div class="text-center mb-6"> <img src=<img src="https://drive.google.com/uc?export=view&id=1NRPdcQkYotz8pa9vG1YU7qlt79MVH0Lg" width="70" class="mx-auto mb-3" alt="Logo">> <h2 class="text-xl font-semibold text-gray-800">ระบบตรวจสอบรายชื่อ</h2> <p class="text-gray-600">ผู้ได้รับทุนการศึกษาบุตรสมาชิกประจำปี 2569</p> <p class="text-sm text-red-500 mt-1">(สหกรณ์จะโอนเข้าบัญชีสมาชิกในวันที่ 11 ส.ค. 69 เป็นต้นไป)</p> </div> <!-- SEARCH FORM (แก้ตรง onsubmit ดักการเด้งหน้าขาวที่นี่!) --> <form id="search-form" onsubmit="event.preventDefault(); handleFormSubmit(this);" class="max-w-md mx-auto mb-8"> <div class="mb-4"> <input type="text" class="form-control form-control-lg text-center" id="searchtext" name="searchtext" placeholder="กรอกเลขสมาชิก 6 หลัก" pattern="\d{6}" maxlength="6" minlength="6" title="กรุณากรอกเฉพาะตัวเลข 6 หลัก" required> </div> <button id="searchBtn" type="submit" class="w-full bg-[#1e3a8a] hover:bg-blue-800 text-white font-medium py-3 px-4 rounded-lg shadow-md transition duration-200 flex justify-center items-center gap-2"> <span id="btnText">ค้นหาข้อมูล</span> <span id="spinner" class="spinner-border spinner-border-sm d-none" role="status" aria-hidden="true"></span> </button> <div class="mt-4 text-center"> <a href="https://drive.google.com/drive/folders/1LfIDo6xXF8uiSIr2p8Ypg2BBSLmyo_sT?usp=sharing" target="_blank" class="inline-flex items-center justify-center gap-2 w-full bg-gray-50 hover:bg-gray-100 text-gray-700 font-medium py-2 px-4 rounded-lg border border-gray-200 transition duration-200 text-sm md:text-base"> 📄 ไฟล์ตรวจสอบรายชื่อผู้ได้รับทุนฯ ปี 2569 </a> </div> </form> <!-- TABLE OF SEARCH RESULTS --> <div id="search-results" class="table-responsive text-center"></div> </div> </main> <!-- JS --> <script> function handleFormSubmit(formObject) { const btn = document.getElementById('searchBtn'); const btnText = document.getElementById('btnText'); const spinner = document.getElementById('spinner'); // ปรับปุ่มเป็นสถานะโหลด btn.disabled = true; btnText.innerText = "กำลังค้นหา..."; spinner.classList.remove('d-none'); // เรียกฟังก์ชันค้นหาจาก Code.gs google.script.run.withSuccessHandler(createTable).processForm(formObject); } function createTable(dataArray) { const btn = document.getElementById('searchBtn'); const btnText = document.getElementById('btnText'); const spinner = document.getElementById('spinner'); const div = document.getElementById('search-results'); // คืนค่าปุ่มกลับเป็นปกติ btn.disabled = false; btnText.innerText = "ค้นหาข้อมูล"; spinner.classList.add('d-none'); if(dataArray && dataArray.length > 0){ let result = `<table class='table table-bordered table-striped mt-4'> <thead class='bg-gray-100 text-[#1e3a8a] text-center' style='white-space: nowrap'> <tr> <th class='py-3'>หมายเลขสมาชิก</th> <th class='py-3'>ชื่อ - สกุล</th> <th class='py-3'>สังกัด</th> <th class='py-3'>ชื่อบุตร</th> <th class='py-3'>ระดับการศึกษา</th> <th class='py-3'>ทุนที่ได้รับ</th> </tr> </thead> <tbody>`; dataArray.forEach(row => { result += `<tr class='align-middle text-center'>`; row.forEach(cell => result += `<td class='py-2'>${cell}</td>`); result += `</tr>`; }); result += `</tbody></table>`; div.innerHTML = result; } else { div.innerHTML = `<div class='alert alert-warning mt-4 text-center text-red-600 font-medium'>ไม่พบข้อมูลผู้ขอทุน! กรุณาตรวจสอบหมายเลขสมาชิกอีกครั้ง</div>`; } } </script> </body> </html>. (line 139)