samedi 16 mai 2020

Select a random element from a dynamic array in HTML

I'd like to add HTML to a Google Site that allows a user to press a button that displays a random letter of the alphabet. However, it should randomize only the letters that the user selects through checkboxes. Below is an image of what I'd like to achieve, and I'd like the result to display to the right of the checkbox array.

enter image description here

As to what I have tried so far, I have the following code that I modified from an open source online. I hope it is ok for my purpose.

<!DOCTYPE html>
<html>
<body>

<h1>Pick Letters To Randomize</h1>

<form action="/action_page.php">
  <input type="checkbox" id="letter1" name="letter1" >
  <label for="letter1"> A</label><br>
  <input type="checkbox" id="letter2" name="letter2" >
  <label for="letter2"> B</label><br>
  <input type="checkbox" id="letter3" name="letter3" >
  <label for="letter3"> C</label><br><br>
  <input type="submit" value="Randomize">
</form>

</body>
</html>

But I am really at a loss for how to solve the rest of my problem.




Aucun commentaire:

Enregistrer un commentaire