+ 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
18 Answers
+ 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.
+ 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?
+ 10
You can use this api: https://picsum.photos/
+ 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");
+ 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.
+ 5
can you give me one example so that i will understand easily
+ 5
Thank you
+ 5
Thank you yadcubox
+ 5
Use a random integer and use it as an index to an array of images.
+ 4
i need randomly select images
+ 4
Thank you Sonic
+ 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
+ 3
Elina, you are welcome !
syntax <DL>...</DL> is Definition List
+ 3
Thank you Burey
+ 3
สิ่งที่ดี
+ 2
กรุณาอย่าสแปม Nyi Nyi
+ 1
Hii