Greetings guys I have the following code
function botonver(a, b) {
imgnormal = "media/imagen/pdf.png";
tituloboton = "Ver PDF ";
botonpdf = "<img class = 'clase2' src = '" + imgnormal + "' width = '50%' />";
iniciotb = 4;
return "<a title = '" + tituloboton + b.substring(iniciotb) + "' target = '_blank' href = '" + a + "' >" + botonpdf + "</a>";
}
I would like to know how I can simplify it to use fixed variables file and title, the only thing that varies is the number and it will always be the same number that is when you want to show the button of file01 the title will be of the same number ie file01, title01
Just like this I must place the outputs as follows:
botonver(archivo07, titulo07)
But I would like to know how I can implement to make an exit with a shorter code something like:
botonver(07)
An example of the output I have running is this:
function leccion02() {
var archivo02 = ruta[02] + "Como hacer un Inicio.pdf";
var titulo02 = "Hacer un Inicio Perfecto";
contenidos = [
{ a: "<h4 class = 'media-heading'>" + titulo02 + "</h4> texto.",
b: botonver(archivo02, titulo02)
},
];
resultado = "";
resultado += cabecera;
for (key in contenidos) {
resultado += "<div class = 'row well well-lg '> <div class = 'col-xs-12 col-sm-6 text-justify'>" + contenidos[key].a + "</div> <div class = 'col-xs-12 col-sm-6 text-center '>" + contenidos[key].b + "</div> </div>";
};
resultado += "</div> </div>";
document.getElementById('contenido').innerHTML =
resultado;
}
But I do not know how to make it work as I described it in my practice