window.onload = function () { document.getElementById('physicalAttackForm').addEventListener('submit', function (event) { event.preventDefault(); // Prevent the form from submitting the normal way const dac = parseInt(document.getElementById('dac').value, 10); const awc = parseInt(document.getElementById('awc').value, 10); const ahd = parseInt(document.getElementById('ahd').value, 10); const modifier = parseInt(document.getElementById('modifier').value, 10); const queryParams = new URLSearchParams({ dac: dac, awc: awc, ahd: ahd, modifier: modifier }); fetch(`${window.BASE_URL}/gameplay/attack/physical?${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 += `
`; if (data['outcome']) { let outcomeText = data['outcome']; html += `

${outcomeText}

`; // adding img tag let outcomeImage = `${window.IMG}/` + outcomeText.replace(' ', '%20') + '.png'; html += `` resultsDiv.innerHTML = html; } }) }); }