title: Updating content to the database onclick event
body: <p>I spent the last 2 days trying to make the following code work.<br />
  I have three forms with content in different languages. For each of them there is an Edit button which popup a text editor. What I would like to do is when I click the button "Save and close" the edited content would be updated in the database using javascript (AJAX) and PHP/SQL but in the console it gives me the following error: <b>Uncaught ReferenceError: valueContent is not defined</b>. So here is the code I have so far.</p>
  
  <pre><code>$mvccont .=
      "&lt;form action='edit_language/".ID.".raw' method='post' target='pop' class='comparelist' style='clear: both' onsubmit='window.open(\"\", \"pop\", \"width=0,height=0,resizeable,scrollbars\");'&gt;".
          "&lt;input type='hidden' name='keyword' value='".$keyword."'&gt;".
          "&lt;table style='width:100%; border-collapse: collapse;' &gt;".
          "&lt;tr&gt;&lt;td width='20%' &gt;&lt;div class='info' style='width:100%; border:none;' &gt;".
              substr($keyword, 0, 20)."&lt;a title='".$keyword."'&gt;&lt;input type='submit' value='Save' class='BUYN'/&gt;&lt;/a&gt;".
              "&lt;a href='edit_language/".$keyword."/delete'&gt;&lt;input type='button' value='Delete' class='NONA'/&gt;&lt;/a&gt;".
          "&lt;/div&gt;&lt;/td&gt;";
  
          foreach($lan as $lang=&gt;$lame) {
              $idk = str_replace(" ", "", $keyword).$lang;
              $mvccont .=
              "&lt;td&gt;&lt;div class='number3'".(($red[$keyword][$lang]=='')?" style='background: #fcc;'":"")." style='border:none;' &gt;".
                  "&lt;input type='hidden' name='touch".$lang.$keyword."'/&gt;".
                  "&lt;input type='text' id='s".$idk."' name='a".$lang."' value='".htmlentities($lame, ENT_QUOTES, "UTF-8")."' onchange=\"this.style.borderColor='#ff0000'; document.getElementsByName('touch".$lang.$keyword."')[0].value='true'\"/&gt;&lt;a onclick='popbox(false, ".$idk.", true); mce();'&gt;&lt;input type='button' value='Edit' class='BUYN'/&gt;&lt;/a&gt;".
                  "&lt;br /&gt;".($red[$keyword][$lang]).
                  "&lt;script&gt;".
                      "function falaffel".$idk."(step) {".
                          "var l".$idk."=document.getElementById('s".$idk."').value;".
                          "if(step==1) {".
                              "return '&lt;textarea&gt;'+l".$idk."+'&lt;/textarea&gt;&lt;input type=\"button\" value=\"Save &amp; close\" class=\"NONA\" onclick=\"'+\"document.getElementById('s".$idk."').value=tinyMCE.activeEditor.getContent(); ".$idk."=falaffel".$idk."(1); popboxremove(); document.getElementById('s".$idk."').style.borderColor='#ff0000'; updateValue(); document.getElementsByName('touch".$lang.$keyword."')[0].value='true' \"+'\"&gt;';".
                          "}".
                          "return l".$idk.";".
                      "}".
                      "var ".$idk." = falaffel".$idk."(1); ".
                  "&lt;/script&gt;".
              "&lt;/div&gt;&lt;/td&gt;";
          }
          $mvccont .=
      "&lt;/tr&gt;&lt;/table&gt;&lt;/form&gt;";
  </code></pre>
  
  <p>Then here is the AJAX code:</p>
  
  <pre><code>function updateValue(){
  var ajaxRequest = getXmlHttpRequestObject();
  
  ajaxRequest.onreadystatechange = function(){
      if(ajaxRequest.readyState == 4){
          var valueContent = document.getElementsByTagName("input");
      }
  }
  ajaxRequest.open("POST", "comp/update_lang.php", true);
  ajaxRequest.send(valueContent);
  }
  </code></pre>
  
  <p>And finally the PHP code:</p>
  
  <pre><code>&lt;?php
  foreach(array(1=&gt;"en", 2=&gt;"it", 3=&gt;"pl") as $id=&gt;$lang) {
      if($_POST["touch".$id.$_POST["keyword"]]=="true") {
          $sql = "UPDATE translat SET value='".mysql_real_escape_string($_POST["a".$id])."', date=".NOWTIME." WHERE lang=".$id." AND keyword='".urldecode($_POST["keyword"])."'";
          $insert = $db-&gt;query($sql);
          $insert-&gt;execute();
          @unlink(TEMP."lang_".$lang.".cache");
      }
  }
  $mvccont .=
  "&lt;script&gt;".
      "window.close();".
  "&lt;/script&gt;";
  die($mvccont);
  ?&gt;
  </code></pre>
  
  <p>Thank you so much for your help.</p>