i'm trying to get it so, depending on if the input value is 0 or 1, the value of the input is one or two, and it's supposed to show up in console.
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>demo</title>
<meta charset="utf-8">
<style>
</style>
</head>
<body>
<p>Input 0 or 1.</p>
<input id="ok" type="text">
<button onclick="functionn()"></button>
<script>
var x = document.getElementById("ok").value;
function functionn() {
if (x == 0) {
ok = "one";
console.log(ok); }
else if (x == 1) {
ok = "two";
console.log(ok);
} else {
alert("please input 0 or 1");
}
}
</script>
</body>
</html
Aucun commentaire:
Enregistrer un commentaire