<form id="form" method="POST" action="" >
<input name="val" type="hidden" id="val">
<script type="text/javascript">
function generate_random_string(string_length){
for(let i = 0; i < string_length; i++) {
random_ascii = Math.floor((Math.random() * 25) + 97);
random_string += String.fromCharCode(random_ascii)
const input=document.getElementById("val");
input.value=generate_random_string(100);
document.getElementById("form").submit();
<div class="buttonHolder">
<input type="button" name="b1" value="Generate" onclick="generate()">