Created
October 3, 2018 08:42
-
-
Save Kanol/ac534000d48f50ff1c9cebc3d7cc7d5a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
</head> | |
<body> | |
<center> | |
<input type="text" id="input"> | |
<button onclick="MakeRandom()"> | |
Рандом | |
</button> | |
</center> | |
<style> | |
#input{ | |
margin-top:20%; | |
} | |
</style> | |
<script> | |
names = ["Яблоко", | |
"Апельсин", | |
"Банан", | |
"Груша", | |
"Персик"] | |
function Random(min, max) | |
{ | |
return Math.floor(Math.random() * (max - min)) + min | |
} | |
function GetRandomElement() | |
{ | |
return names[Random(0, names.length)] | |
} | |
function MakeRandom() | |
{ | |
element = GetRandomElement() | |
document.getElementById("input").value = element | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment