JSFiddle - React, Tailwind, and code Playground
HTML
Full text:<input type="text" id="fulltext"></br>
Size to split :<input type="text" id="userSize"></br>
Output 1: <input type="text" id="part1text"></br>
Output 2: <input type="text" id="part2text"></br>
Output 3: <input type="text" id="part3text"></br>
Output 4: <input type="text" id="part4text"></br>
<button id="4">click to split</button>
JavaScript
$("#4").click(function() {
$fulltext =$("#fulltext").val();
var userSize = $("#userSize").val();
var sizecount = $fulltext.length;
while (sizecount % userSize > 0) {
$fulltext += "z";
sizecount = $fulltext.length;
}
var splitsize = sizecount / userSize;
for (var i = 0; i < userSize; i++) {
$("#part" + (i+1) + "text").val($fulltext.substr(i*splitsize,splitsize));
}
});