Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Laravel LocalStorage getItem returning null

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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");
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading