A
A
Alexander Sergeevich2020-01-15 15:57:46
Programming
Alexander Sergeevich, 2020-01-15 15:57:46

How to write a program to randomly display given data?

Hello, dear inhabitants of the forum.
The task is this. They asked me to help create a small program for a children's quiz.
Its essence lies in the fact that when you click on the button, in one window, randomly, one of the prepared images is displayed, and in the other, also randomly, one of the blocks of text.
Picture to visualize the task:
5e1f09f9b4ed3025645829.jpeg
PS It would be nice to implement this as a web program (here I at least know the meaning of the words HTML, CSS, PHP and JS)
PSS I'm not asking for a ready-made solution, just tell me where to start and in what direction to move.
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
twobomb, 2020-01-15
@Shurik93

https://jsfiddle.net/twobomb/antLjwq9/

G
Gip, 2020-01-15
@Giperoglif

1. clicking on the button sends an ajax request to the server.
2. PHP server script accepts a request and returns a random object in JSON from a predefined array {'image':'url', 'text':'текст'}
3. js on the client overwrites the corresponding HTML blocks with data from the response. profit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question