Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取并设置localStorage中的javascript值_Javascript_Php_Local Storage - Fatal编程技术网

获取并设置localStorage中的javascript值

获取并设置localStorage中的javascript值,javascript,php,local-storage,Javascript,Php,Local Storage,我想使用LocalStorage获取javascript值,并在php中存储一个值。我不知道如何设置一个值,所以请为我提供解决方案 var getdate1 = document.getElementById("eventDayName").innerHTML = selectedDate.toLocaleString("en-US", { month: "long", day: "numeric", year: "nume

我想使用LocalStorage获取javascript值,并在php中存储一个值。我不知道如何设置一个值,所以请为我提供解决方案

var getdate1 = document.getElementById("eventDayName").innerHTML = selectedDate.toLocaleString("en-US", {
            month: "long",
            day: "numeric",
            year: "numeric"
        }); 


        localStorage.getItem('getdate1', val);
使用此代码:

// Store
localStorage.setItem("lastname", "Smith");

//get
localStorage.getItem("lastname");
使用此代码:

// Store
localStorage.setItem("lastname", "Smith");

//get
localStorage.getItem("lastname");

要在localStorage中设置值,请使用
window.localStorage.setItem
like

window.localStorage.setItem('getdate1', JSON.stringify(getdate1));
var getdate1=document.getElementById(“eventDayName”).innerHTML=selectedDate.toLocaleString(“en-US”{
月:“长”,
日期:“数字”,
年份:“数字”
}); 

setItem('getdate1',JSON.stringify(getdate1))
要在localStorage中设置值,请使用
window.localStorage.setItem
类似

window.localStorage.setItem('getdate1', JSON.stringify(getdate1));
var getdate1=document.getElementById(“eventDayName”).innerHTML=selectedDate.toLocaleString(“en-US”{
月:“长”,
日期:“数字”,
年份:“数字”
}); 

setItem('getdate1',JSON.stringify(getdate1))我想设置一个变量并分配给php值,这是主逻辑。(例如)php值在这里是什么意思?您可以通过id为inputvar x=localStorage.getItem(“lastname”)的输入将其绑定$('#inputid').val(x);我想设置一个变量并将其赋值给php值,这是主逻辑。(例如)php值在这里是什么意思?您可以通过id为inputvar x=localStorage.getItem(“lastname”)的输入将其绑定$('#inputid').val(x);这回答了你的问题吗?这回答了你的问题吗?该值将设置为localStorage.setItem(“getdate1”,getdate1)//get var getval=localStorage.getItem(“getdate1”);如何将此值设置为php内部值@sixthstar@sixthstar set javascript或php ValueGrate,先生。很好。非常感谢。值将设置为localStorage.setItem(“getdate1”,getdate1)//get var getval=localStorage.getItem(“getdate1”);如何将此值设置为php内部值@sixthstar@sixthstar set javascript或php ValueGrate,先生。很好,非常感谢。