I have implemented a dropdown box that allows users to select one of eight images, which is then displayed on the webpage. However, currently the image appears directly above the dropdown box and I would like to format it so that the image is shown on the left with the dropdown box on the right. I am unsure how to adjust the CSS since these two elements are connected, and I'm not sure if using div classes would be effective.
Below is the code snippet:
<img id="imageToSwap" src="kittens1.jpg"/>
<select id="kittenlist" onChange="swapImage()">
<option value="kittens1.jpg">Image 1</option>
<option value="kittens2.jpg">Image 2</option>
<option value="kittens3.jpg">Image 3</option>
<option value="kittens4.jpg">Image 4</option>
<option value="kittens5.jpg">Image 5</option>
<option value="kittens6.jpg">Image 6</option>
<option value="kittens7.jpg">Image 7</option>
<option value="kittens8.jpg">Image 8</option>
</select>
<script type="text/javascript">
function swapImage(){
var image = document.getElementById("imageToSwap");
var dropd = document.getElementById("kittenlist");
image.src = dropd.value;
};
</script>