Use javascript variables in php : <p>I have to read the values of multiple elements, put them into variables and then write them with default text to a file. I'm now using javascript and php. I hope you can help me. I am possibly open to other solutions.</p>

<p>This is what I have right now:</p>

<pre><code>    &lt;script&gt;

  function createfile(){
    var maximum = x;
    var element = 0;

    var Element_exists = document.getElementById(element);
    if(Element_exists){

      function toggle(Element_exists){
          if(Element_exists.tagName === 'Input'){
              var p_name = document.getElementById(element).value;
              var p_font = document.getElementById(element + "_font").value;
              var p_fontsize = document.getElementById(element + "_fontsize").value;
              var total_p = "&lt;/p&gt;"+ p_name + " new text "+ p_font +" even more new text " + p_fontsize + " last bit of text&lt;/p&gt;"
          }else{

          }
      }

      &lt;?php
      $myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
      $txt = total_p;
      fwrite($myfile, $txt);
      fclose($myfile);
      ?&gt;

    }
  }
  &lt;/script&gt;
</code></pre>
