I have written HTML \ JavaScript code. The HTML page getting the three details from the end user. Based on the input from the user i want that javascript generate the barcode numbers and download the report as txt file. Here variable "B12" is a Barcode number.
Code is shown here :
const AL = document.getElementById("N1").value;
var to = Number(document.getElementById("N3").value);
var i = 1
var barcode = "1" + document.getElementById("N2").value;
while (i < to) {
const myArray = barcode.split("");
let B1 = myArray[1] * 8
let B2 = myArray[2] * 6
let B3 = myArray[3] * 4
let B4 = myArray[4] * 2
let B5 = myArray[5] * 3
let B6 = myArray[6] * 5
let B7 = myArray[7] * 9
let B8 = myArray[8] * 7
let B9 = B1 + B2 + B3 + B4 + B5 + B6 + B7 + B8
let B10 = B9 % 11
let B11 = 11 - B10
B11 = B11 === 10 ? '0' : B11;
B11 = B11 === 11 ? '5' : B11;
rem = barcode.substring(1);
let B12 = AL + rem + B11 + "IN"
i++;
barcode++;
}
<form id="my-form">
<label for="T1">BARCODE FIRST TWO CHARATER</label><br><br>
<input type="" text " maxlength="2 " onkeyup="this.value=t his.value.toUpperCase(); " id="N1 " onchange="validity.valid||(value='' ) " required> <br><br>
<label for="T2 ">Barode Starting Eight Numbers:</label><br><br>
<input type="text " pattern="[0-9]{8} " maxlength="8 " onchange="validity.valid||(value='' ) " id="N2 " required ><br><br>
<label for="T3 ">Number of Barcode (Max 1000):</label><br><br>
<input type="number " id="N3 " min="1 " max="1000 " onchange="validity.valid||(value='' ) " required ><br><br>
<center><button type="submit " name="myButton ">Submit</button></center>
</form>
I want that javascript loop generate the report with the variable value "B12" and download as a text file while user click on submit button. Please help in the matter.