title: get Value from a div tag
body: <p>I have the following situation and I know have a lot of this subject here in stackoverflow, but no answers give a real solution, so I'm posting again.</p>
  
  <p>First take a look at this code:</p>
  
  <pre><code>&lt;tr&gt;
      &lt;td align="right"&gt;Estado&lt;/td&gt;&lt;td&gt;
          &lt;select name="estado" onChange="javascript:Atualiza(this.value,'0');"&gt;
              &lt;option&gt;[selecione]&lt;/option&gt;
              &lt;?
              $qry = "SELECT nome, uf FROM tb_estados"; 
              $res = mysql_query($qry);
              while ($ln = mysql_fetch_array($res)) { 
                  echo "&lt;option value='$ln[uf]'&gt;".$ln['nome']."&lt;/option&gt;"; 
              }
              ?&gt;
          &lt;/select&gt;
      &lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>and Now at this piece of code</p>
  
  <pre><code>&lt;tr&gt;
       &lt;td align="right"&gt;Cidade&lt;/td&gt;
       &lt;td&gt;&lt;div id="atualiza"&gt;&lt;/div&gt;&lt;/td&gt;
  &lt;/tr&gt; 
  </code></pre>
  
  <p>I have a linked combo, to show states and cities.</p>
  
  <p><strong>Now my problem:</strong>
  I can not get the value from my <code>&lt;div id="atualiza"&gt;</code> the values of <code>&lt;select name="estado"</code> no problem cause it is an object of my form but the div tag is not an object of the form. 
  I need to <code>INSERT INTO</code>  my database the value of <code>&lt;div id="atualiza"&gt;</code> </p>
  
  <p><strong>How to do this?</strong></p>
  
  <p>I would like to save the value inside an hidden field and send in my form to insert in my database.</p>
  
  <p>I had a similar situation before and I solved the problem, but it was so bizarre and I know there is an easy way to do that.</p>
  
  <p><strong>The Atualiza function</strong></p>
  
  <pre><code>function Atualiza(valor,cid) 
  { 
      loadXMLDoc("combo_cidade.php",valor,cid); 
  }
  </code></pre>
  
  <p><strong>Also my page combo_cidade.php</strong></p>
  
  <pre><code>&lt;?php 
  echo "&lt;select name='cidade' id='cidade'&gt;"; 
  echo "&lt;option&gt;[selecione]&lt;/option&gt;"; 
  
  # my databse connection
  include_once("config/config.php");
  
  $sql = "SELECT tb_cidades.nome, tb_cidades.id FROM tb_cidades INNER JOIN tb_estados ON tb_cidades.uf=tb_estados.uf WHERE tb_cidades.uf='".$_GET["uf"]."'";
  $resultado = mysql_query($sql); 
  while ($linha = mysql_fetch_array($resultado)){ 
      if ($_GET["cid"]==$linha["id"]){$sel="selected";}else{$sel="";}
      echo "&lt;option value='$linha[id]' $sel&gt;$linha[nome]&lt;/option&gt;"; 
  } 
  echo "&lt;/select&gt;"; 
  
  
  ?&gt;
  </code></pre>
  
  <p><strong>Here goes the whole script that handle my combo</strong></p>
  
  <pre><code>// JavaScript Document
  var req; 
  
  function loadXMLDoc(url,valor,cid) 
  { 
      req = null; 
      // Procura por um objeto nativo (Mozilla/Safari) 
      if (window.XMLHttpRequest) { 
          req = new XMLHttpRequest(); 
          req.onreadystatechange = processReqChange; 
          req.open("GET", url+'?uf='+valor+'&amp;cid='+cid, true); 
          req.send(null); 
      // Procura por uma versao ActiveX (IE) 
      } else if (window.ActiveXObject) { 
          req = new ActiveXObject("Microsoft.XMLHTTP"); 
          if (req) { 
              req.onreadystatechange = processReqChange; 
              req.open("GET", url+'?uf='+valor+'&amp;cid='+cid, true); 
              req.send(); 
          } 
      } 
  } 
  
  function processReqChange() 
  { 
      // apenas quando o estado for "completado" 
      if (req.readyState == 4) { 
          // apenas se o servidor retornar "OK" 
          if (req.status == 200) { 
              // procura pela div id="atualiza" e insere o conteudo 
              // retornado nela, como texto HTML 
              document.getElementById('atualiza').innerHTML = req.responseText;           
          } else { 
              alert("Houve um problema ao obter os dados:\n" + req.statusText); 
          } 
      } 
  } 
  
  function Atualiza(valor,cid) 
  { 
      loadXMLDoc("combo_cidade.php",valor,cid); 
  }
  </code></pre>