PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 28, 2022

[FIXED] Laravel LocalStorage getItem returning null

 February 28, 2022     javascript, laravel     No comments   

Issue

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


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");


Answered By - jszobody
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing