Project: An editable HTML email template
Goal: Create a user friendly set of inputs that, upon form submission, gathers the inputted text and inserts it between specified p tags. The code that makes the email template is in a textarea at the bottom of the page, from which the user can copy the HTML and paste it into an email without having to go into the HTML to make changes. Each input in the form has an ID, as do their respective tags in the HTML where I want the inputted text to appear
Here is the form:
<body>
<div id="content">
<div id="field">
<form id="myForm" action="">
<h2> Header </h2>
<textarea id="header" cols="40" rows="5"></textarea>
<h2>Draft Details </h2>
<textarea id="draft" cols="40" rows="5"></textarea>
<h2>Event 1 Image (left)</h2>
<input id="ev1Img" type="file">
<h2>Event 1 Details </h2>
<textarea id="ev1Det" cols="40" rows="5"></textarea>
<h2>Event 2 Image (right)</h2>
<input id="ev2Img" type="file">
<h2>Event 2 Details</h2>
<textarea id="ev2Det" cols="40" rows="5"></textarea>
<button type="submit">Generate Email Code</button>
</form>
</div>
The text area at the bottom (which contains the HTML template) has p tags with their own IDs:
<p id="Xheader"></p> ...etc
I am trying to use Javascript and Jquery to grab the input data and populate my p tags in the HTML:
<script>
var dataY = document.getElementById("header", "draft", "ev1Det", "ev2Det").text();
var dataX = document.getElementById("Xheader", "Xdraft", "Xev1Det","Xev2Det").text();
document.ready(function() {
document.getElementById("button").click(function() {
dataX.text() = dataY.text();
});
});
</script>
What are some solutions to make this work? Am I on the right track? I'm sure my JS/ JQ is where the problem is