mercredi 31 mai 2017

How to include JS objects in HTML

I have this code from my JS File:

var formStr = "<h5>How many books?:</h5><input type='number' id='bookinput'
value='' /><input type='button' value='submit' onclick='addbook();' />"
infowindow = new google.maps.InfoWindow();
infowindow.setContent(formStr);
infowindow.setPosition(location);
infowindow.open(map);

JS variable formStr has html code as you can see above. I want to be able to put JS variables into this without moving the HTML out of my JS file. Something like:

var objectType='book';
var formStr = "<h5>How many *objectType*?:</h5><input type='number' id='bookinput' value='' /><input type='button' value='submit' onclick='addbook();' />"




Aucun commentaire:

Enregistrer un commentaire