try

/* add style to the form elements */

* { box-sizing: border-box; }
div {
padding: 10px;
background-color: #f6f6f6;
overflow: hidden;
}
input[type=text], textarea, select {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
}
input[type=button]{
width: auto;
float: right;
cursor: pointer;
padding: 7px;
}

— Choose the country —
India
Japan
USA

let saveFile = () => {

// Get the data from each element on the form.
const name = document.getElementById(‘txtName’);
const age = document.getElementById(‘txtAge’);
const email = document.getElementById(‘txtEmail’);
const country = document.getElementById(‘selCountry’);
const msg = document.getElementById(‘msg’);

// This variable stores all the data.
let data =
‘\r Name: ‘ + name.value + ‘ \r\n ‘ +
‘Age: ‘ +age.value + ‘ \r\n ‘ +
‘Email: ‘ + email.value + ‘ \r\n ‘ +
‘Country: ‘ + country.value + ‘ \r\n ‘ +
‘Message: ‘ + msg.value;

// Convert the text to BLOB.
const textToBLOB = new Blob([data], { type: ‘text/plain’ });
const sFileName = ‘formData.txt’; // The file to save the data.

let newLink = document.createElement(“a”);
newLink.download = sFileName;

if (window.webkitURL != null) {
newLink.href = window.webkitURL.createObjectURL(textToBLOB);
}
else {
newLink.href = window.URL.createObjectURL(textToBLOB);
newLink.style.display = “none”;
document.body.appendChild(newLink);
}

newLink.click();
}