JSFiddle - React, Tailwind, and code Playground
HTML
<button onclick="clickHandler(cats)">Cats</button>
<button onclick="clickHandler(dogs)">Dogs</button>
<input type="text" id="url-field">
<script>
var cats = [
'http://www.catprotection.com.au/wp-content/uploads/2014/11/5507692-cat-m.jpg',
'https://i.ytimg.com/vi/mW3S0u8bj58/maxresdefault.jpg',
'https://s-media-cache-ak0.pinimg.com/564x/92/9d/3d/929d3d9f76f406b5ac6020323d2d32dc.jpg'
];
var dogs = [
'https://images-na.ssl-images-amazon.com/images/G/01/img15/pet-products/small-tiles/23695_pets_vertical_store_dogs_small_tile_8._CB312176604_.jpg',
'http://r.ddmcdn.com/w_830/s_f/o_1/cx_0/cy_220/cw_1255/ch_1255/APL/uploads/2014/11/dog-breed-selector-australian-shepherd.jpg',
'https://www.cesarsway.com/sites/newcesarsway/files/styles/large_article_preview/public/Why%20dogs%20eat%20grass_0.jpg?itok=fu5yHnol'
];
function randomUrl(urls){
return urls[Math.floor((Math.random() * urls.length))];
}
function clickHandler(animals){
document.querySelector('#url-field').value=randomUrl(animals)
}
</script>