+ 16

How to generate random images?

I have created a new web app "corona virus precution" in that app i have use random sentence to generate. Now instead of texts i want to generate images please help me. Code : https://code.sololearn.com/WvH45NyeXs48/?ref=app

1st Mar 2020, 6:11 AM
🌸 Elina RL Shah 🌸
🌸 Elina RL Shah 🌸 - avatar
18 Respostas
+ 2
Thank you all for your help now i get it. I will be implementing this ideas from my next projects. Again thank you all.
2nd Mar 2020, 9:00 PM
🌸 Elina RL Shah 🌸
🌸 Elina RL Shah 🌸 - avatar
+ 10
I have to admit that this 'horoscope' is among the least needed ideas I've seen in weeks. That said, do you want to generate images or randomly select one image from a bunch as you do with text snippets?
1st Mar 2020, 8:41 AM
::sк::
::sк:: - avatar
+ 10
You can use this api: https://picsum.photos/
2nd Mar 2020, 1:18 PM
Burey
Burey - avatar
+ 6
Salut ELINA, Perhaps like that image = new Array(3); link = new Array(3); image[0] = 'http://users../images/header1.jpg' image[1] = 'http://users../images/header2.jpg' image[2] = 'http://users../images/header3.jpg' image[3] = 'http://users../images/header4.jpg' link[0] = 'http://users../' link[1] = 'http://users../02.htm' link[2] = 'http://users../03.shtml' link[3] = 'http://users../javascript' index = Math.floor(Math.random() * image.length); document.write("<DL>\n"); document.write("<A HREF="+link[index]+">"); document.write("<IMG SRC="+image[index]+"></A>"); document.write("</DL>\n");
2nd Mar 2020, 9:57 AM
yadcubox
yadcubox - avatar
+ 5
Take image URLs/filename in a list and reuse the same approach as with text. Put the URL into the src attribute of img.
1st Mar 2020, 8:51 AM
::sк::
::sк:: - avatar
+ 5
can you give me one example so that i will understand easily
1st Mar 2020, 9:03 AM
🌸 Elina RL Shah 🌸
🌸 Elina RL Shah 🌸 - avatar
+ 5
Thank you
1st Mar 2020, 9:13 AM
🌸 Elina RL Shah 🌸
🌸 Elina RL Shah 🌸 - avatar
+ 5
Thank you yadcubox
2nd Mar 2020, 10:01 AM
🌸 Elina RL Shah 🌸
🌸 Elina RL Shah 🌸 - avatar
+ 5
Use a random integer and use it as an index to an array of images.
2nd Mar 2020, 1:50 PM
Sonic
Sonic - avatar
+ 4
i need randomly select images
1st Mar 2020, 8:50 AM
🌸 Elina RL Shah 🌸
🌸 Elina RL Shah 🌸 - avatar
+ 4
Thank you Sonic
2nd Mar 2020, 1:58 PM
🌸 Elina RL Shah 🌸
🌸 Elina RL Shah 🌸 - avatar
+ 4
E L I N A please do not mark your own comment as best answer as this is seen as a selfanswer / best answer. Thanks and happy coding... Two: Did you actually get your answer if not try this https://code.sololearn.com/Wcq3ZxyHSAjD/?ref=app
2nd Mar 2020, 11:47 PM
BroFar
BroFar - avatar
+ 3
Elina, you are welcome ! syntax <DL>...</DL> is Definition List
2nd Mar 2020, 10:32 AM
yadcubox
yadcubox - avatar
+ 3
Thank you Burey
2nd Mar 2020, 2:01 PM
🌸 Elina RL Shah 🌸
🌸 Elina RL Shah 🌸 - avatar
+ 3
สิ่งที่ดี
3rd Mar 2020, 2:29 AM
Nyi Nyi
Nyi Nyi - avatar
+ 2
กรุณาอย่าสแปม Nyi Nyi
3rd Mar 2020, 2:33 AM
BroFar
BroFar - avatar
+ 1
Hii
2nd Mar 2020, 9:06 AM
Uday pratap Singh
Uday pratap Singh - avatar
2nd Mar 2020, 8:55 PM
hea ra
hea ra - avatar