window.onload = function () { document.getElementById('mentalAttackForm').addEventListener('submit', function (event) { event.preventDefault(); // Prevent the form from submitting the normal way const ams = parseInt(document.getElementById('ams').value, 10); const dms = parseInt(document.getElementById('dms').value, 10); const modifier = parseInt(document.getElementById('modifier').value, 0); const queryParams = new URLSearchParams({ ams: ams, dms: dms, modifier: modifier }); fetch(`${window.BASE_URL}/gameplay/attack/mental?${queryParams}`) .then(response => response.json()) .then(data => { const resultsDiv = document.getElementById('results'); let html = ''; if (data['needed']) { html += `
Needed: ${data['needed']} `; } if (data['original-roll']) { html += `Original Roll: ${data['original-roll']}
`; } if (data['modifier']) { html += `Modifier: ${data['modifier']} `; } if (data['adjusted-roll']) { html += `Adjusted Roll: ${data['adjusted-roll']}
`; } html += `