Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
HTML
HELP, I have A solution from my friend.

i created 2 html to passing to another html. See this code:

*----PAGE1----*
<html>
<body>
<form action="page2.html">
Please enter your name: <input name="user"/>
<br/>
Then <input type="submit" value="click here" />
</form>
</body>
</html>



*----PAGE2----*
<html>
<head>
<script type="text/javascript">
var pairs = location.search.substring(1).split( "&" );
var name = "anonymous";
for ( var p = 0; p < pairs.length; ++p )
{
    var pair = pairs[p].split("=");
    if ( pair[0] == "user" ) name = unescape( pair[1].replace(/\+/g," ") );
}
</script>
<body>
<h1>WELCOME</h1>
<br/>
<h2>To our friend, 
<script type="text/javascript">document.write(name);</script>
</h2>
<br/>
Hope you enjoy this site.
</body>
</html>

>>>>>>>>>>>>>><<<<<<<<<<<<

My Question
I can Add more Input type in PAGE 1 
example :

<input name="user"/>
<input name="age"/>
<input name="from"/>
<input name="zip"/>

but i dont know modify SCRIPT Source code PAGE 2 If you know this problem, please give a solution.

Thanks,….


What I have tried:

Please help me, to accept this question because i'm have this from my teacher in high school
Posted
Updated 30-Aug-16 17:09pm
Comments
David_Wimbley 30-Aug-16 23:09pm    
What issue are you having?
Yudhi Saputra 30-Aug-16 23:16pm    
i can add this code in Page 1

<input name="age"/>
<input name="from"/>
<input name="zip"/>

Please tell. i dont know set this script (script from Page 2)

<script type="text/javascript">
var pairs = location.search.substring(1).split( "&" );
var name = "anonymous";
for ( var p = 0; p < pairs.length; ++p )
{
var pair = pairs[p].split("=");
if ( pair[0] == "user" ) name = unescape( pair[1].replace(/\+/g," ") );
}
</script>
Yudhi Saputra 31-Aug-16 0:04am    
See Expample Picture hire https://scontent.fsub2-1.fna.fbcdn.net/v/t34.0-12/14169476_120300000084175433_1268679186_n.jpg?oh=986e500c9248f0f4d3cb708edea3ca13&oe=57C82467

1 solution

IS example code

var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};

// Store
localStorage.setItem("info1", person );
// Retrieve
document.getElementById("result").innerHTML = localStorage.getItem("info1");
 
Share this answer
 
v2
Comments
Yudhi Saputra 30-Aug-16 23:11pm    
Thanks but Where, i add this code ? i dont know about Html, this is mision from my teacher, my age is 14, Please...
Beginner Luck 30-Aug-16 23:13pm    
It is a javascript. when you debug you can see it. get item is
localStorage.setItem("name", pairs);
localStorage.name; // get from "name"
for more info :
https://developer.mozilla.org/en/docs/Web/API/Window/localStorage
Yudhi Saputra 30-Aug-16 23:20pm    
thank you friend, I'll wait for the next input which may be more detail, because I do not know exactly about HTML and script, I just do the job of a teacher
Yudhi Saputra 31-Aug-16 0:05am    
See Example Picture Hire : https://www.befunky.com/explore/gallery/9960030/
Beginner Luck 31-Aug-16 0:13am    
create object and store in the local storage
this how you create object
http://www.w3schools.com/js/js_objects.asp

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900