Home > Mobile >  Laravel LocalStorage getItem returning null
Laravel LocalStorage getItem returning null

Time:02-23

I'm having some trouble retrieving values from localStorage. I'm trying to get item from this : enter image description here

My input :

<input type="text" name="kd_lokasi2" id="kd_lokasi_kasir"> 
<input type="text" name="kd_shift2" id="kd_shift_kasir">

My script :

document.getElementById("kd_lokasi_kasir").innerHTML = localStorage.getItem("kd_lokasi");
document.getElementById("kd_shift_kasir").innerHTML = localStorage.getItem("kd_shift");

And use @kd_lokasi_kasir = '".$request->kd_lokasi2."' and @kd_shift = '".$request->kd_shift2."' on my controller. It not working.

enter image description here

CodePudding user response:

If you want to set the value of an input, you need to use .value and not .innerHTML, like this:

document.getElementById("kd_lokasi_kasir").value = localStorage.getItem("kd_lokasi");
  • Related