Javascript how to pass variable value to next page using GET?

I am using Javascript and JQuery for mobile app code for my school assignment. I am trying to pass the value of variable days to another page using the get function, the codes below are what I have done so far. What I'm trying to do here is assign an id variable to result.html so that I can call it on a schedule. Html However, the value of the variable does not appear in sched.html when "write.document-ed", resulting in [Object Object] instead.

result.html

<html>
var days = (weight/0.064); 
var days= document.getElementById('myday').value;
</html>

schedule.html

<html>
var days;
var days = document.getElementById('myday').value;
write.document(day);
</html>

4 , htmls js . html , index.html, result.html. Common.js html , .

, common.js , index.html result.html , :

index.html

 function bigfunction(){
    var weight = 
    smallfunction(parseFloat(document.form.Weight.value));
    document.form.weight.value = weight;
    document.form.submit()

common.js

smallerfunction(weight){
var weight = weight;
}

result.html

<script>
var weight;
 weight = decodeURIComponent(getUrlVars()["weight"]);
</script>

Weight = <script>document.write(weight)</script>

, , , result.html schedule.html, result.html . Jquery , , - DOM , , .. , , get, , DOM , !!!!

: localstorage

result.html

var days = localStorage.setItem("days", days);

schedule.html

var days;
days = localStorage.getItem("days");
days: document.write(days)

alll!!!!!!!!!!!!!!!!!!!!!!!!!!

+4
2

, :

( , ), ( ):

// setter
localStorage.setItem("data", { date: 'whatever', anotherKey: 'somevalue' });
// getter
var data = localStorage.getItem("data");

, , sessionStorage ( /), ( )

// setter
sessionStorage.setItem("data", { date: 'whatever', anotherKey: 'somevalue' });
// getter
var data = sessionStorage.getItem("data");

, localStorage , , /.

+2

: localstorage

result.html

var days = localStorage.setItem("days", days);

schedule.html

var days;
days = localStorage.getItem("days");
days: document.write(days)
0

Source: https://habr.com/ru/post/1617465/


All Articles