-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (21 loc) · 920 Bytes
/
script.js
File metadata and controls
26 lines (21 loc) · 920 Bytes
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 people = {
1: { name: "รัชพล ชายทวีป", age: 20, animal: "แมว,หมา"},
2: { name: "บุผารัตน์ นิลศรี", age: 38, animal: "แมว" },
3: { name: "วรรณ ศรีแย้ม", age: 20, animal: "กระต่าย" }
};
function getQueryParam(param) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param);
}
const personId = getQueryParam("person");
const profileDiv = document.getElementById("profile");
if (people[personId]) {
const p = people[personId];
profileDiv.innerHTML = `
<p><strong>ชื่อเล่น:</strong> ${p.name}</p>
<p><strong>อายุ:</strong> ${p.age}</p>
<p><strong>สัตว์ที่ชอบ:</strong> ${p.animal}</p>
`;
} else {
profileDiv.innerHTML = `<p>ไม่พบข้อมูล</p>`;
}