Skip to content

Instantly share code, notes, and snippets.

@Kanol
Created October 3, 2018 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kanol/ac534000d48f50ff1c9cebc3d7cc7d5a to your computer and use it in GitHub Desktop.
Save Kanol/ac534000d48f50ff1c9cebc3d7cc7d5a to your computer and use it in GitHub Desktop.
<!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