I am trying to set a custom width and height for the url images in my javascript function. Could someone show me a simple way to achieve this? Currently they are different sizes and I would like to be able to control each ones dimensions separately.
var IMAGE_SOURCE = "";
var IMAGE_EXTENSION = "";
// const IMAGE_SOURCE = "https://example.com/images/";
// const IMAGE_EXTENSION = ".png";
function tests() {
let combo = document.getElementById("string_determine");
let div = document.getElementById("mybox");
let string_determine;
switch (combo.options[combo.selectedIndex].text) {
case '"red" + "blue"':
string_determine = "purple";
div.style.color = "purple";
IMAGE_SOURCE = "https://www.kindpng.com/picc/m/48-486841_purple-paint-splatter-clipart-purple-paint-splatter-clip";
IMAGE_EXTENSION = ".png";
break;
case '"blue" + "green"':
string_determine = "turquoise";
div.style.color = "turquoise";
IMAGE_SOURCE = "https://p.kindpng.com/picc/s/428-4289893_turquoise-splotch-svg-clip-arts-yellow-colour-splash";
IMAGE_EXTENSION = ".png";
break;
case '"green" + "red"':
string_determine = "brown";
div.style.color = "brown";
IMAGE_SOURCE = "https://www.pngkey.com/png/detail/28-287400_splatter-vectors-photos-and-psd-files-brown-paint";
IMAGE_EXTENSION = ".png";
break;
default:
string_determine = "NONE";
}
let myBoxHTML = `<p>${string_determine}</p><img src="${IMAGE_SOURCE}${string_determine}${IMAGE_EXTENSION}">`;
console.log(myBoxHTML);
document.getElementById("mybox").innerHTML = myBoxHTML;
}
<!doctype html>
<html>
<select name="string_determine" id="string_determine">
<option value=>Select Value</option>
<option value='"red" + "blue"'>"red" + "blue"</option>
<option value='"blue" + "green"'>"blue" + "green"</option>
<option value='"green" + "red"'>"green" + "red"</option>
</select>
<button onclick="tests()">Yes</button>
<div class="container">
<h3>Selection</h3>
<div id="mybox" class="box">
</div>
</div>
<script src="script.js" async defer></script>
</html>