title: Dynamically changing HTML form using javascript
body: <p>Basically I need to change the elements in a form based on a choice (radio button perhaps).
  So that 2 forms are potentially available on a page.</p>
  
  <p>So far I've come up with this but it doesn't seem to work...</p>
  
  <pre><code>//javascript
  
  function FormChange(toChange){
      if (toChange){
          var oldHTML = document.getElementById('li1').innerHTML;
          var newHTML = "Company Name: " + "&lt;input type="text" name="companyname" /&gt;";
          document.getElementById('li1').innerHTML = newHTML;
  }
  
  //HTML
  
  &lt;form action="insert.php" method="post"&gt;
  &lt;li id="li1"&gt;Firstname: &lt;input type="text" name="firstname" /&gt;
  &lt;/form&gt;
  
  &lt;input type = "button" value="Change that bad boy" onclick="FormChange(true)"/&gt;
  </code></pre>
  
  <p>My Intention was to remove the firstname field and replace it with the companyname field.</p>
  
  <p>Any help is greatly appreciated, thanks. </p>