title: Pass javascript to php in modal window
body: <p>I am trying to pass a javascript variable to php in a modal window, all on the same page, which is edit.php. (I'll figure out how to do it with separate pages later). In the meanwhile, this javascript code works to pass the variable to the modal:</p>
  
  <pre><code> &lt;script type="application/javascript"&gt;
   $(document).on("click", ".open-EditRow", function () {
     var myGroupId = $(this).data('id');
     $(".modal-body #groupId").val( myGroupId );
   });
   &lt;/script&gt;
  </code></pre>
  
  <p>In the modal window, here is the code I have been working with:</p>
  
  <pre><code> &lt;div class="modal hide fade" id="myEditModal"&gt;
   &lt;div class="modal-body"&gt;
   &lt;form class="well-small" action="" method="POST" id="modalForm" name="modalForm"&gt;
     &lt;?php ********* code *********** ?&gt;
   &lt;/form&gt;
   &lt;/div&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>Inside the form is where I have my php code where I successfully retrieve the groupId from the javascript and where I am able to print it to the screen with an input tag.  Here is the code:</p>
  
  <pre><code> &lt;?php
     $id = "&lt;input type=\"text\" name=\"groupId\" id=\"groupId\" value=\"\" /&gt;";
     echo "Group Id: " . $id;
     $sql = "SELECT mygroup FROM mytable WHERE pk_tId = '" . $id . "'";
     $result = mysql_query($sql);
     if(mysql_data_seek($result)){
       $row = mysql_fetch_row($result);
     }
     else {
       echo "Cannot seek row: " . mysql_error() . "\n";
     }
   ?&gt;
  </code></pre>
  
  <p>The sql statement cannot find $id in the database because $id is being printed as an input tag. How can I extract the groupId out of the input tag so that my sql statement will work?</p>
  
  <p>Example, please. Thank you in advance.</p>