title: document.getElementById() as PHP SQL Query parameter
body: <p>I have a question, is it possible to use the value stored in <code>document.getElementById().value</code>, <code>getElementsByName().value</code>, <code>getElementsByClassName().value</code> as a parameter for SQL Query via PHP?</p>
  
  <p>Example.</p>
  
  <p>I have this line <code>&lt;input type="text" class="myinput" id="myinput" name="myinput" value="999-AAA-000"&gt;</code></p>
  
  <p>Then I'll store the data in this element.</p>
  
  <pre><code>&lt;script&gt;
  function myFunction() {
    var foroutput = document.getElementsByClassName("myinput");
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Is there a way for <code>document.getElementsByClassName("myinput")</code>, or <code>var foroutput</code> to be used as a parameter for SQL Query via PHP?</p>
  
  <p>SCENARIO: The SQL Query is within the same page as the <code>document.getElementsByClassName("myinput")</code>, will this work without using <code>&lt;form&gt;</code>?</p>
  
  <p>This is my code</p>
  
  <pre><code>&lt;input type="text" class="decid" id="decid" name="decid"&gt; 
  // the data passed into this input box will be used as a parameter for SQL Query $id
  
  
  &lt;table id="example2" class="table table-bordered"&gt;
  &lt;thead&gt;
  &lt;th&gt;Schedule Date&lt;/th&gt;
  &lt;th&gt;Schedule Name&lt;/th&gt;
  &lt;th&gt;Recorded In&lt;/th&gt;
  &lt;th&gt;Recorded Out&lt;/th&gt;
  &lt;th&gt;Day Count&lt;/th&gt;
  &lt;th&gt;Day Value&lt;/th&gt;
  &lt;th&gt;N.D. Value&lt;/th&gt;
  &lt;th&gt;Leave Count&lt;/th&gt;
  &lt;th&gt;R.H. Count&lt;/th&gt;
  &lt;th&gt;R.H. Value&lt;/th&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
  &lt;?php 
  $id=$_POST['id'];
  $sql = "SELECT fingerscanno, scheduledate, schedulename, recordin, recordout, noofdays, rate, nightdifferential, leaveday, regularholiday, specialholiday, referenceno
  FROM payrollrecords WHERE fingerscanno='$user' and referenceno='$id'";
  
                      $query = sqlsrv_query($conn, $sql, array(), array("Scrollable" =&gt; SQLSRV_CURSOR_KEYSET));
                      while($row = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC)){
  
   echo "
                          &lt;tr&gt;
                            &lt;td&gt;".$row['scheduledate']."&lt;/td&gt;
                            &lt;td&gt;".$row['schedulename']."&lt;/td&gt;
                            &lt;td&gt;".$row['recordin']."&lt;/td&gt;
                            &lt;td&gt;".$row['recordout']."&lt;/td&gt;
                            &lt;td&gt;".$row['noofdays']."&lt;/td&gt;
                            &lt;td&gt;".$row['rate']."&lt;/td&gt;
                            &lt;td&gt;".$row['nightdifferential']."&lt;/td&gt;
                            &lt;td&gt;".$row['leaveday']."&lt;/td&gt;
                            &lt;td&gt;".$row['regularholiday']."&lt;/td&gt;
                            &lt;td&gt;".$row['specialholiday']."&lt;/td&gt;
                          &lt;/tr&gt;
                        ";
  }
  
                    ?&gt;
                    &lt;/tbody&gt;
                &lt;/table&gt;
  </code></pre>
  
  <p>A sample would be extremely great. Thank you.</p>
  
  <p>EDIT: </p>
  
  <p>Why won't this work?</p>
  
  <pre><code>&lt;input type="text" class="decid" id="decid" name="decid"&gt;
  &lt;script type="text/javascript"&gt;
  var abc = document.getElementById("decid").value;
  &lt;?php $abc = "&lt;script&gt;document.write(abc)&lt;/script&gt;"?&gt;   
  &lt;/script&gt;
  &lt;?php echo $abc;?&gt;
  </code></pre>