I would just like to start by saying I am very new to HTML so forgive the poor code structure and lack of knowledge.
I have created a form in which the user fills out a few details about their daily exercises, the name of the log entry, name of exercise etc.. I then use some java functions to store these values and then on a separate page I want to display these values back to the user in a textbox format. My issue is I want to display all the values inside 1 textbox, but I do not know how to read them out in this format.
This is the HTML where I create and save the user input:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Add New Log</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="CSS/New Log.css">
<script src="JavaScript/New Log.js"></script>
</head>
<body>
<script type = "text/JavaScript">
function save() {
// save values into localStorage
localStorage['input1'] = document.getElementById('eName').value;
localStorage['input2'] = document.getElementById('exercise').value;
localStorage['input3'] = document.getElementById('date').value;
localStorage['input4'] = document.getElementById('sTime').value;
localStorage['input5'] = document.getElementById('eTime').value;
localStorage['input6'] = document.getElementById('cal').value;
alert("Log Entry Saved");
};
</script>
<h1> Add New Log </h1>
<form id="contact-form">
<label for="name">Log entry name:</label>
<input type="text" id = "eName" value="" placeholder="Run at the
park"/>
<label for="email">Name of exercise:</label>
<input type="name" id = "exercise" value="" placeholder="Jogging" />
<div id="line">
<label> ------------------------------ <span class="required">
</span></label>
</div>
<div id="detail">
<label for="telephone">Date: </label>
<input type="number" id = "date" value="" />
<label for="telephone">Start Time: </label>
<input type="number" id = "sTime" value="" />
<label for="telephone">End Time: </label>
<input type="number" id = "eTime" value="" />
<label for="telephone">Calories Lost: </label>
<input type="number" id = "cal" value="" />
</div>
</form>
<li><a href="Fitness Log.html" onclick ="save()"> Add New Log</a></li>
</body>
</html>
Here when the add new log button is clicked, the user information is stored.
This is where I want to load the information inside just 1 textbox:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Health and Fitness</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
<link rel="stylesheet" href="CSS/Log.css">
</head>
<body>
<script>
window.onload = function(){
var val = localStorage.getItem('input1'); // or localStorage.value
if(val == null)
val = "First try";
document.getElementById("textbox").value = val;
}
</script>
<h1> Fitness Log </h1>
<p> Fitness Log keeps track of the exercise you complete and saves it to
your account.</p>
<div>
<ul>
<li><a href="New Log.html"> Add Log</a></li>
<li><a href="#"> Delete All</a></li>
</ul>
</div>
<input type="text" id = "textbox" value = "change"> </input>
<input type="text" id = "textbox2" value = "change"> </input>
</body>
<script>
</html>
I know I can load all this information from the user in separate text boxes, but I want to load all of it, not just input1 into the textbox. I don't know if this is the best way to do this, if there is a better way please let me know.