I have a JS variable set var myvar = 0; Easy.
I want to run an form onsubmit function that says if a field with a specific ID exists get that value and reset myvar to this value.
Easy enough if I know it's there
var myvar = parseInt(document.getElementById('inputID').value);
But if inputID doesn't exist I want to leave it at 0;