function setResult(first, second, destination){ // get the value from item1 var selector = document.getElementById(first); var valueOne = selector[selector.selectedIndex].value; var nameOne = selector[selector.selectedIndex].text; // get the value from item2 selector = document.getElementById(second); var valueTwo = selector[selector.selectedIndex].value; var nameTwo = selector[selector.selectedIndex].text; // do maths var result = valueTwo/valueOne; // construct sentence var sentence = "There are " + result + " " + nameOne + "s in a " + nameTwo ; // set sentence console.log("#"+destination); document.getElementById(destination).innerHTML = sentence; } Marathon Mount Everest Football Pitch Blue Whale iPhone 7 in a Marathon Mount Everest Football Pitch Blue Whale iPhone 7 Go! Earth Texas France Wales Isle of Wight Football Pitch Olymic swimming pool Blue whale Double decker bus Matchbox in a Earth Texas France Wales Isle of Wight Football Pitch Olymic swimming pool Blue whale Double decker bus Matchbox Go!