Skip to content

Commit 40be4b6

Browse files
committed
Update: changeQTN updated.
1 parent a3ca648 commit 40be4b6

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

dom/changeQTN.html

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ <h3 style="color: #1A434E">Scan for join</h3>
189189
<input type="number" class="input-box" value="1" min="1" max="10" readonly="readonly">
190190
<button type="button" class="plus" aria-label="Increase">&plus;</button>
191191
</div>
192-
<button id="result" class="btn" type="submit">Purchase New Ticket (${{ticket_price}})</button>
192+
<input style="display: none;" step="0.01" type="number" class="totalprice" name="price">
193+
<button class="btn" type="submit">Purchase New Ticket $ <span class="showPrice"></span></button>
193194
</form>
194195
{% endif %}
195196
</div>
@@ -203,12 +204,6 @@ <h3 style="color: #1A434E">Scan for join</h3>
203204
const img = document.getElementById('myImage');
204205
// Set the src attribute of the image element
205206
img.src = `data:image/png;base64,${base64String}`;
206-
207-
// Change ticket price on click
208-
let ticket_price = "{{ event.single_ticket_price|escapejs }}"
209-
const button = document.getElementById('showDataButton');
210-
211-
console.log(ticket_price);
212207
</script>
213208

214209
<script>
@@ -219,6 +214,7 @@ <h3 style="color: #1A434E">Scan for join</h3>
219214
const inputBox = quantityContainer.querySelector(".input-box");
220215

221216
updateButtonStates();
217+
calcualtePrice();
222218

223219
quantityContainer.addEventListener("click", handleButtonClick);
224220
inputBox.addEventListener("input", handleQuantityChange);
@@ -229,11 +225,26 @@ <h3 style="color: #1A434E">Scan for join</h3>
229225
plusBtn.disabled = value >= parseInt(inputBox.max);
230226
}
231227

228+
// Change ticket price on click
229+
function calcualtePrice() {
230+
let value = parseInt(inputBox.value);
231+
let ticket_price = "{{ event.single_ticket_price|escapejs }}"
232+
//let result = document.querySelector(".showPrice").innerHTML = ticket_price * value;
233+
let result = ticket_price * value;
234+
let final_price = result.toFixed(2);
235+
document.querySelector(".showPrice").innerHTML = final_price;
236+
document.querySelector(".totalprice").value = final_price;
237+
}
238+
232239
function handleButtonClick(event) {
233240
if (event.target.classList.contains("minus")) {
234241
decreaseValue();
242+
// Change ticket price on click
243+
calcualtePrice();
235244
} else if (event.target.classList.contains("plus")) {
236245
increaseValue();
246+
// Change ticket price on click
247+
calcualtePrice();
237248
}
238249
}
239250

@@ -256,10 +267,7 @@ <h3 style="color: #1A434E">Scan for join</h3>
256267
function handleQuantityChange() {
257268
let value = parseInt(inputBox.value);
258269
value = isNaN(value) ? 1 : value;
259-
260-
// Execute your code here based on the updated quantity value
261-
console.log("Quantity changed:", value);
262-
}
270+
}
263271
})();
264272
</script>
265273
</body>

0 commit comments

Comments
 (0)