How do I make it so that when I click on the try button, it executes the script and downloads the information? Thank you.
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script>
function mostrar() {
var miArray = [ 10, 20, 40, 65 ];
var miArray2= [15, 26, 44, 71];
var miArray3 = ["TaT","Pan","Aut","Caf"];
var mostrar = "";
for (var i=0; i<miArray.length; i++) {
for (var j=miArray[i]; j<=miArray2[i]; j++) {
mostrar += j + " "+miArray3[i];
}
}
document.getElementById("resultado").innerHTML = mostrar;
}
</script>
<button onclick="mostrar();">Probar</button>
<div id="download('Desgarga', 'resultado')"></div>
</body>
Download file function taken from https://stackoverflow.com/a/33542499/1423096 by Ludivic Feltz
For Internet Explorer compatibility, it first checks to see if the function msSaveOrOpenBlob exists .
If it does not exist, a more standards-compliant browser is assumed and a link is created that has the binary representation of the file's content, is added to the document and the link is clicked, which triggers a download file.
For this we use the functions
if you only want to show the content in that
div
all you have to do is give it an id and send the valueI hope it helps you