title: getElementById breaks script
body: <p>I'm working on a little project, but I'm stuck and don't know what I'm doing wrong.<br />
  I use Ajax to call a php-script that updates a MYSQL-row.</p>
  <p>The javascript:</p>
  <pre><code>function savecust()
  {
  if (window.XMLHttpRequest)
    {
    xmlhttp=new XMLHttpRequest();
    }
  else
    {
    xmlhttp=new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
    }
  xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
      {
      document.getElementById(&quot;custdetails&quot;).innerHTML=xmlhttp.responseText;
      }
    }
  xmlhttp.open(&quot;GET&quot;,&quot;./ajax/savecust.php?id=&quot; + document.getElementById('id').value,true); //More arguments should still be passed.
  xmlhttp.send();
  }
  </code></pre>
  <p>If I remove the <code>document.getElementById('id').value</code> the script works and does what is is supposed to do. (I get the response from the PHP, obviously</p>
  <p>I load the script in the head of the page along with some other scripts:</p>
  <pre><code>&lt;script src=&quot;js/custedit.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
  </code></pre>
  <p>This is how I call the script:</p>
  <pre><code>&lt;input type='button' onclick='savecust()' value='Save' /&gt;
  </code></pre>
  <p>Any help would be greatly appreciated ;-).</p>
  <p>Thanks!</p>
  <h2>EDIT</h2>
  <ul>
  <li>The div where the content should go, exists.</li>
  <li>The PHP-scripts returns an error for now (because it doesn't get all the required parameters)</li>
  <li>The content (and textfield with id: 'id') is loaded by another script. Is this a problem? If you look at the source in a browser the textfields are not there. They are however visible in the browser.</li>
  </ul>
  <h2>EDIT 2</h2>
  <p>So, I ran this test on top of my script:</p>
  <pre><code>var thisid = 'id';//should get info from &lt;input type='text' name='id' /&gt;
  var T = document.getElementById(thisid);
  if (T) {
       alert(&quot;element exists&quot; + T.value);
  } else {
  alert(&quot;nothing to be found&quot;);
  }
  </code></pre>
  <p>It is indeed unable to find the element. This pointed me in the right direction.<br />
  <code>&lt;input type='text' name='id' /&gt;</code>is inserted by another Ajax-script. So I think the second script is unable to find it.</p>
  <p>How do I solve this?</p>