[Solved] How to find id of input field when getElementById does not work?
I didn’t wait for my DOM to fully load. Thank you all for the help. solved How to find id of input field when getElementById does not work?
I didn’t wait for my DOM to fully load. Thank you all for the help. solved How to find id of input field when getElementById does not work?
Solved changing from document.getElementById (‘thingsID’). InnerHTML to document.getElementById (‘thingsID’).value In Example: function myCalc() { var num1 = document.getElementById(‘WG_Collected’).value; var num2 = document.getElementById(‘Proof’).value; var PG_Collected = parseFloat(num1) * parseFloat(num2)/100; document.getElementById(‘PG_Collected’).innerHTML = PG_Collected.toFixed(2); } document.getElementById(“WG_Collected”).addEventListener(“change”, myCalc, true); document.getElementById(“Proof”).addEventListener(“change”, myCalc, true); Change to: function myCalc() { var num1 = document.getElementById(‘WG_Collected’).value; var num2 = document.getElementById(‘Proof’).value; var PG_Collected = parseFloat(num1) … Read more
You’re going to want to make a reference to that element, so you don’t end up looking it up each time it’s clicked and you’ll need a variable to keep track of whether it’s been clicked or not: var cancelButton = document.getElementById(‘btn_Cancel’), clicked = false; cancelButton.addEventListener(‘click’, function() { clicked = !clicked; }, false); // assuming … Read more
I have found couple of issues here. You have two form tags which is un-necessary and the form tags needs to have a name and id. Atleast name attribute must be there. Check the following fiddle http://jsfiddle.net/ayyadurai/3Ru9T/ <form name=”form1″ id=”form1″> <input type=”button” id=”button” value=”click” onClick=”what()” /> <input type=”text” id=”text” value=”hey” /> </form> var button = … Read more
You’re not passing the data from your index.html to game.html. So when you call this: <a href=”https://stackoverflow.com/questions/55249162/game.html” class=”button” id=”startCyber”>START</a> You’re loading a new page, which removes all of your existing variables – including ‘color1’. I see 2 options here: Make this a single-page web app. So when you click your START button, it hides the … Read more