I am attempting to create a couple of web pages that will allow me to fill out a form on input.html
and have the entered data appended to a different HTML file, index.html
.
I have been searching for an answer for a couple of hours now and it might just drive me insane!
Here is some example code of what I'm trying to do:
- HTML form
input.hmtl
:
<form>
<label>
Enter something:
<input type="text" id="userinput" required>
</label>
<input type="submit" id="submit" value="submitted">
</form>
- Javascript to get entered data and pass to
index.html
:
var userInput = document.querySelector("#userinput");
var submit = document.querySelector("#submit");
function addToIndex()
{
// create new element on index.html
}
submit.addEventListener("click", addToIndex, false);
- HTML output file
index.html
:
<div id="contentstart">
<!-- newly created element here -->
</div>
I have attempted using this solution, but Chrome's console gives me an error and tells me that newWindow is not a function
. I just stumbled upon using the <iframe>
element in a couple of answers but don't quite understand it yet (I'm a noob).
Thanks in advance!