@if(session()->has('product')) <script> document.getElementById('prodName').value = session()->get('product')->name; </script> @endif code example
Example: getelementbyid
document.getElementById("someid");
document.getElementById("someid");