I'm in trouble with saving a word in Javascript ! I want to save the document as "x" by concatenating several vars. I tried the following:
<script>// SAVE AS WORD
var fname = document.getElementsByName("fname")[0].value;
var name = document.getElementsByName("name")[0].value;
var company = <?php echo json_encode($company); ?>;
function exportHTML(){
var header = "<html xmlns:o='urn:schemas-microsoft-com:office:office' "+
"xmlns:w='urn:schemas-microsoft-com:office:word' "+
"xmlns='http://www.w3.org/TR/REC-html40'>"+
"<head><meta charset='utf-8'><title>Export HTML to Word Document with JavaScript</title></head><body>";
var footer = "</body></html>";
var sourceHTML = header+document.getElementById("pdf").innerHTML+footer;
var source = 'data:application/vnd.ms-word;charset=utf-8,' + encodeURIComponent(sourceHTML);
var fileDownload = document.createElement("a");
document.body.appendChild(fileDownload);
fileDownload.href = source;
**fileDownload.download = concat(fname,'-',name,'-LM-',company,'.doc');**
fileDownload.click();
document.body.removeChild(fileDownload);
}
</script>
The save-as line is the following :
**fileDownload.download = concat(fname,'-',name,'-LM-',company,'.doc');**
Any idea ? Thanks a lot from France !