They only taught us how to inline script in school so I was looking on the internet. I found something but it doesn't work.
The code I have right now : DEMO FIDDLE
<title>DPS</title>
<body>
<form id="value-input">
<input type="text" name="damage" id="damage" placeholder="Damage">
<input type="text" name="firerate" id="firerate" placeholder="Firerate">
<input type="button" id="submit" value="Calculate">
<input type="reset">
</form>
<script src="main.js"></script>
</body>
function calc() {
var damage = document.getElementById('damage');
var firerate = document.getElementById('firerate');
alert(newFirerate * newDamage);
}
document.querySelector('submit').addEventListener('onClick', calc);
It's really basic and it's just to learn how to develop Chrome apps, without using inline scripts.
There are a few errors here as I can see it.
First off, you're not currently getting the values from the inputs, only getting the inputs themselves. Do this instead:
var damage = document.getElementId('damage').value;
var firerate = document.getElementById('firerate').value;
Next up, in your alert you're using variables "newFirerate" and "newDamage" which you have not defined anywhere. I assume you want to use the ones you have defined:
alert(firerate * damage);
And lastly, in your event listener, change 'onClick' to 'click'.
EDIT: Also change the query selector when adding the event listener from 'submit' to '#submit'.