page name 3.html
<html>
<body>
<form action="4.html" onSubmit="cal()">
<table>
<tr>
<td><input type="text" id="sen"/></td>
<td><input type="submit" value="tap me"/></td>
</tr>
</table>
</form>
</body>
<script>
function call(){
var a = document.getElementById("sen").value;
localStorage.setItem("a",a);
}
</script>
</html>
page name 4.html
<html>
<body>
<table>
<tr>
<td><p id="r"></p></td>
</tr>
</table>
</body>
<script>
var get = localStorage.getItem('sen');
alert(get);
document.getElementById("r").innerHTML=get;
</script>
</html>
i am trying to pass value from 3.html to 4.html but it is passing null value. why is it passing the null value? how to resolve this error?
CodePudding user response:
Looks like you have an error when calling the function onSubmit="cal()"
The defined function name is call()
Apart that you are trying to set the session with key a and retrieve it with key seen.