title: Copy text into textbox when paragraph is clicked
body: <p>Just starting a web programming class and need a little help with an assignment. It says to "Copy all the text inside your new paragraph element into the textbox with the id of name-input." This is what I have so far.</p>
  
  <p><strong>JS:</strong></p>
  
  <pre><code>document.addEventListener('DOMContentLoaded', function () {
  
      'use strict'; // Enforce stricter JavaScript rules.
  
      // Declare this function's local variables.
      var howdyElement, nameInputElement, nameOutputElement, submitNameButton webappideaElement;
  
      // Find all needed elements and save them in variables.
      nameInputElement = document.querySelector('#name-input');
      submitNameButton = document.querySelector('#submit-name');
      howdyElement = document.querySelector('#howdy');
      nameOutputElement = document.querySelector('#name-output');
      webappideaElement = document.querySelector('#webappidea');
  
      // Make things happen when a user clicks on the button element.
      submitNameButton.addEventListener('click', function () {
          var name;
  
          // Get the string value out of the input textbox.
          name = nameInputElement.value;
  
          if (name.length === 0) {
              // The user didn't input a name, so use a default.
              nameOutputElement.textContent = 'student';
              howdyElement.classList.remove('enthusiastic');
          } else {
              // The user did input a name, so use it.
              nameOutputElement.textContent = name;
              // Make the paragraph stand out more.
              howdyElement.classList.add('enthusiastic');
          }
      }, false);
  
  }, false);
  </code></pre>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en-US"&gt;&lt;head&gt;
  
      &lt;meta charset="UTF-8" /&gt;
      &lt;title&gt;Gotta start somewhere&lt;/title&gt;
  
  
      &lt;!-- Import a CSS stylesheet to style the page. --&gt;
      &lt;link href="style.css" rel="stylesheet" /&gt;
  
  &lt;/head&gt;&lt;body&gt;
  
      &lt;!-- Page content goes here.  Elements can be nested inside other elements. --&gt;
      &lt;h1&gt;Welcome to CS 3312&lt;/h1&gt;
      &lt;p&gt;
          What is your name?&amp;nbsp;
          &lt;input id="name-input" type="text" /&gt;
          &lt;button id="submit-name" type="button"&gt;Submit it&lt;/button&gt;
      &lt;/p&gt;
      &lt;p class="greeting" id="howdy"&gt;
          Howdy, &lt;span id="name-output"&gt;student&lt;/span&gt;!
      &lt;/p&gt;
  
      &lt;h2&gt;Brainstorms&lt;/h2&gt;
      &lt;p class="info" id="webappidea"&gt; Text&lt;/p&gt;
  
      &lt;!-- Import a JavaScript script to add interactivity to the page. --&gt;
      &lt;script src="script.js"&gt;&lt;/script&gt;
  
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>