Skip to content
Advertisement

How to create drop-down lists and randomly show one of the items chosen?

There are 4 text boxes existing in the piece of code below. You can type everything you want within these four text boxes and when you click the “Pick one” button, you will get back the text you’ve entered within the text boxes. But I would like to change these text boxes to drop-down lists from which you can select four different teams and when you click the “Pick one” button, randomly, you will get one of the four teams you’ve chosen.

JavaScript

Advertisement

Answer

If you want use drop-down lists instead of text boxes, you can use the piece of code below:

JavaScript

I hope my answer will be useful for you

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement