title: Change script to enter text in a div, not textarea
body: <p>I'm working on a job with a developer who is taking care of coding that's beyond my ability; mostly PHP and more complex Javascript (I'm only <em>okay</em> at jQuery).</p>
  
  <p>Part of the work the developer has been doing involves checking a database and dynamically entering results into the page. The problem is that currently these results are entered into a <code>&lt;textarea&gt;</code>, which is not ideal as it means that if it's readonly, the results cannot be deleted if the user changes their mind. If it's not readonly, the user can enter any text they like into the textarea, rendering the page unusable. In addition, I'm unable to apply any CSS to the results within the textarea.</p>
  
  <p>Also, the developer is using tables, one of my pet hates.</p>
  
  <p>I would like the <code>&lt;textarea&gt;</code> to be instead a <code>&lt;div&gt;</code> containing a <code>&lt;div&gt;</code> for each database result found.</p>
  
  <p>The developer is currently away for a few weeks and I would prefer to get this done sooner rather than later. I've tried changing "td" simply to "div" but obviously that didn't work.</p>
  
  <p>I'd really appreciate some help. I've included the code below. Unfortunately, I'm unable to give access to the live/testing site (beyond my control) and apologise for that.</p>
  
  <pre><code>if(answer)
  {
  
  var newRow = document.getElementById("target_table");
  var Row = newRow.rows.length;   
  var row1 = newRow.insertRow(Row);
  var index=row1.rowIndex;
  var td1= document.createElement("TD")
  var td2= document.createElement("TD")
  td2.innerHTML =  "
  
  &lt;INPUT TYPE='hidden' NAME='course"+Row+"' id='course"+Row+"' value='"+answer+"'&gt;
  &lt;INPUT TYPE='hidden' NAME='ary"+Row+"' id='ary"+Row+"'&gt;
  &lt;INPUT TYPE='hidden' NAME='Dary"+Row+"' id='Dary"+Row+"'&gt;
  &lt;p class='courseName'&gt;"+answer+"&lt;/p&gt;
  &lt;div id='boxRw"+Row+"' class='boxyHolder'&gt;
  
      &lt;TABLE border=1 cellspacing=2&gt;
          &lt;TR&gt;
              &lt;TD&gt;
                  &lt;INPUT TYPE='button' name='Add a favourite to this course' value='Add a favourite to this course' onclick='javascript: window.open(\"&lt;?=$path?&gt;add-my-favourites/"+Row+"\",\"mywindow\",\"left=550,top=200,width=400,height=350,toolbar=1,resizable=0\");'&gt;
              &lt;/TD&gt;
          &lt;/TR&gt;
          &lt;tr&gt;
              &lt;td colspan=2&gt;
                  &lt;TABLE border=1&gt;
                      &lt;TR&gt;
                          &lt;TD valign=top&gt;Favourites:&lt;/TD&gt;
                          &lt;TD&gt;
                              &lt;TEXTAREA class='fav-box' NAME='reps"+Row+"' id='reps"+Row+"' ROWS=4 COLS=45&gt;&lt;/TEXTAREA&gt;
                              &lt;input class='fav-box' TYPE='hidden' NAME='repsId"+Row+"' id='repsId"+Row+"' value=''&gt;
                          &lt;/TD&gt;
                      &lt;/TR&gt;
                  &lt;/TABLE&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;/TABLE&gt;
  
  &lt;/div&gt;"; 
  
  row1.appendChild(td1);
  row1.appendChild(td2);
  
  document.getElementById("h").value=Row;
  }
  
  function setVal(){
      var r = "&lt;?=$_GET['hVal']?&gt;";
      var y = "reps"+r;
  
      var y1 = "repsId"+r;
  
      window.opener.document.getElementById(y).value+=document.frm.favourites.value+',';
      window.opener.document.getElementById(y1).value+=document.frm.recp_listId.value+',';
      window.close();
  }
  </code></pre>
  
  <p>Edit: I believe these are the lines I need to change:               </p>
  
  <pre><code>window.opener.document.getElementById(y).value+=document.frm.recipes.value+',';             
  
  window.opener.document.getElementById(y1).value+=document.frm.recp_listId.value+',';
  </code></pre>
  
  <p>I think the problem is that these lines are adding the value to what is currently a <code>&lt;textarea&gt;</code>. When I change the textareas to divs, the values are not applied to the divs. So I need to change the code so that it enters the results as text in the divs - not values.</p>