Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
Trying to pull from a folder of images

Hi first time here and I'm very new to coding

I'm making a website where its kind of an inside joke about nfts (making fun of them just wanted to be clear)

and I got a bunch of randomly generated images that I want to be selected from to show one at random when you click a button

right now I have this

<script type="text/javascript">
    ImageArray = new Array();
    ImageArray[0] = "https://cdn.discordapp.com/attachments/669350505264447512/912516499862863892/55.png";
    ImageArray[1] = 'https://cdn.discordapp.com/attachments/669350505264447512/912516499531522128/52.png';
    ImageArray[2] = 'https://cdn.discordapp.com/attachments/669350505264447512/912516499208548432/54.png';
    ImageArray[3] = 'https://cdn.discordapp.com/attachments/669350505264447512/912516498898173962/32.png';
    ImageArray[4] = 'https://cdn.discordapp.com/attachments/669350505264447512/912516498617171988/44.png';
    ImageArray[5] = 'https://cdn.discordapp.com/attachments/669350505264447512/912516498390659082/47.png';
    ImageArray[6] = 'https://cdn.discordapp.com/attachments/669350505264447512/912516498138988554/27.png';
    ImageArray[7] = 'https://cdn.discordapp.com/attachments/669350505264447512/912516497883152414/11.png';
    ImageArray[8] = 'https://cdn.discordapp.com/attachments/669350505264447512/912516497686036520/5.png';
    ImageArray[9] = 'https://cdn.discordapp.com/attachments/669350505264447512/912516497459535882/3.png';
    ImageArray[10] = 'https://cdn.discordapp.com/attachments/669350505264447512/912517257987518484/70.png';

function getRandomImage() {
    var num = Math.floor( Math.random() * 11);
    var img = ImageArray[num];
    document.getElementById("randImage").innerHTML = ('<img  src="' + img + '" width="300px,">')

}
</script>
<button onclick="getRandomImage()";>NFT</button>
<div class="parent" id="randImage" ></div>"

and that works pretty well but I don't want to write ImageArray 1 to 100 for every possible image and was wondering if I could somehow write it to where it pulls from a file of all the images

help would be appreciated and also explain as much as possible because I would like to know how to do similar stuff

https://misinformedmember.000webhostapp.com/

above is the website if it helps

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda