1document.addEventListener("DOMContentLoaded", function () { 2 const phoneNumber = "6281128590000"; 3 const postTitle = "<?php echo esc_js(get_the_title()); ?>"; 4 5 // Form Fields 6 const nameInput = document.getElementById("name"); 7 const emailInput = document.getElementById("email"); 8 const serviceSelect = document.getElementById("chooseService"); 9 const dateInput = document.getElementById("date"); 10 const priceDisplay = document.getElementById("priceDisplay"); 11 const bookNowLink = document.getElementById("bookNowLink"); 12 13 function updatePrice() { 14 // Get the selected option 15 const selectedOption = serviceSelect.options[serviceSelect.selectedIndex]; 16 17 // Get the price from the data-price attribute 18 let price = ""; 19 if (selectedOption && selectedOption.dataset.price) { 20 price = selectedOption.dataset.price; 21 } 22 23 // Display the price 24 priceDisplay.textContent = price; 25 26 return price; 27 } 28 29 function updateWhatsAppLink() { 30 const userName = nameInput.value.trim() || "Guest"; 31 const userEmail = emailInput.value.trim() || "No email provided"; 32 const selectedOption = serviceSelect.options[serviceSelect.selectedIndex]; 33 const service = selectedOption 34 ? selectedOption.value 35 : "No package selected"; 36 const chosenDate = dateInput.value; 37 const price = updatePrice(); 38 39 // Build the message 40 let message = 41 "Hello Bali Premium Trip," + 42 "\n\nNama saya " + 43 userName + 44 "\nEmail: " + 45 userEmail + 46 "\nâ Kategori: " + 47 service + 48 "\nâ Tanggal: " + 49 chosenDate + 50 "\nâ Harga: " + 51 price; 52 53 // URL-encode the message 54 let encodedMessage = encodeURIComponent(message); 55 56 // Construct the WhatsApp URL 57 let whatsappURL = 58 "https://api.whatsapp.com/send?phone=" + 59 phoneNumber + 60 "&text=" + 61 encodedMessage; 62 63 // Update the link's href attribute 64 bookNowLink.href = whatsappURL; 65 } 66 67 // Calculate price and update link on any change 68 [nameInput, emailInput, serviceSelect, dateInput].forEach((el) => { 69 el.addEventListener("change", () => { 70 updatePrice(); 71 updateWhatsAppLink(); 72 }); 73 }); 74 75 // Run once on page load to set defaults 76 updatePrice(); 77 updateWhatsAppLink(); 78});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.