I have a button on my website that when clicked generates a word. This word is then used in a url call to download a specific file.
Try this it's working fine :
Html :
<button class="button1" onclick="myFunction();">cafe</button>
Script :
var cafe = [];
window.myFunction = function() {
cafe.push('cafenew');
console.log(cafe);
var name = cafe[0];
var src = "https://www.dropbox.com/s/"+name+".kml?dl=1";
console.log(src);
}
Working fiddle : https://jsfiddle.net/8etxu8pr/