Answer the question
In order to leave comments, you need to log in
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:
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
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 questionAsk a Question
731 491 924 answers to any question