Hey so I’m tryna throw together a little code for fun and practice and I was rocking along good until I ran into this problem and I got a feeling that like with most things coding the issue is super simple and right in front of me. Can someone explain to me where I went wrong?
So in the below code I am trying to take the 4 user inputed variables (sxp, uxp, ess, gxp) and have the function add them together to a fifth value (txp). That’s all Any help is appreciated in advance!
function updateTXP() {
// Totals up all the various kinds of xp to total xp
var sxp = parseInt(document.getElementById("sxp").value);
var uxp = parseInt(document.getElementById("uxp").value);
var ess = parseInt(document.getElementById("ess").value);
var gxp = parseInt(document.getElementById("gxp").value);
document.getElementById("txp").value = Math.floor(sxp + uxp + ess + gxp);
}
I thought maybe it couldn’t handle multiple variable calls in the same line or something so I tried sxp + 2 and it didn’t work either so idk what I’m doing wrong