I am working on getting the user t input a number for something in this case it would be a resistor value, I have asked them via a prompt to pick a number and then if that number is within the limits I have set then the number would be displayed back to the user within a div.
I have built this already and got it to work with a couple of test messages so I believe the function itself is fine however I am having a problem that whenever the user enters a correct value that value isn't displayed but "undefined" is displayed instead.
This is the HTML I am testing,
<button onclick="R1Value()">Change Value</button>
<div id="test3"></div>
And this is the JavaScript function
function R1Value() {
var R1ValueEntered = prompt("please enter a value for R1:")
var R1 = parseInt(R1ValueEntered)
var display = document.getElementById('test3');
if (R1 >= 120 && R1 <= 1000000) {
display.innerHTML = R1.value;
}
else {
alert("That is an incorrect value please enter one between 120Ohms and 1MOhm.");
}
}
I have placed into into a jsfiddle as even though there isn't a lot of code it may save you some time if you can have a look, http://jsfiddle.net/2ufnK/72/ I may be missing something simple but I can't seem to fix the problem.
display.innerHTML = R1.value;Integers don't have avalueproperty.