Skip to content

Commit b8b19e0

Browse files
committed
. . .
1 parent c842e2d commit b8b19e0

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

script.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ function saveParticipantsAndStartSimulation() {
159159
masterContainers.forEach((masterContainer, index) => {
160160
let nameInput = masterContainer.querySelector(".master-name");
161161
console.log(masterContainer.innerHTML); // Log the contents of the master container
162+
// Updated to find the servant dropdown inside the servant-selection div
162163
let servantDropdown = masterContainer.querySelector(".servant-selection .servant-select");
163164
let pictureEl = masterContainer.querySelector(".master-img");
164165

@@ -174,8 +175,9 @@ function saveParticipantsAndStartSimulation() {
174175

175176
if (selectedOption) {
176177
servantId = selectedOption.value || "Unknown";
177-
servantName = selectedOption.dataset.name || selectedOption.textContent || "Unknown";
178-
}
178+
servantName = selectedOption.dataset && selectedOption.dataset.name
179+
? selectedOption.dataset.name
180+
: selectedOption.textContent || "Unknown";
179181

180182
console.log(`Selected Servant (from option): id=${servantId}, name=${servantName}`);
181183
} else {
@@ -204,6 +206,7 @@ function saveParticipantsAndStartSimulation() {
204206
}
205207

206208

209+
207210
//code to attach the above function to the button:
208211
document.addEventListener("DOMContentLoaded", function () {
209212
const startButton = document.getElementById("simulation");

0 commit comments

Comments
 (0)