How do I pass a .js variable to HTML input

I have been looking for a way to pass a js function to a HTML input. Is there any easy way to do that or my approach is wrong?

    <script>
            const input = window.location.search
            const clientID = input.split('?clientID=').pop()
   </script>

    <form action="" method="POST">
        <input type="submit">
    </form>