-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (23 loc) · 1.06 KB
/
Copy pathscript.js
File metadata and controls
26 lines (23 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const planButtons = document.querySelectorAll(".select-plan");
const planSelect = document.querySelector('select[name="plan"]');
const bookingForm = document.querySelector(".booking-form");
const message = document.querySelector(".form-message");
planButtons.forEach((button) => {
button.addEventListener("click", () => {
planSelect.value = button.dataset.plan;
document.querySelector("#booking").scrollIntoView({ behavior: "smooth" });
message.textContent = `已选择:${button.dataset.plan}`;
});
});
bookingForm.addEventListener("submit", (event) => {
event.preventDefault();
const data = new FormData(bookingForm);
const name = data.get("name");
const pet = data.get("pet");
const plan = data.get("plan");
const time = data.get("time");
const followUpTime = data.get("followUpTime");
const note = data.get("note").trim();
const noteText = note ? `备注:${note}。` : "";
message.textContent = `${name},已生成 ${pet} 的“${plan}”预约摘要,期望到店时间:${time},回访时间:${followUpTime}。${noteText}`;
});