send html input as variable into jquery which then sends it to PHP
<p>i am new to jquery, i have only recently discovered its amazing use so be easy on me please.</p>

<p>What i am trying to do is have an html input  text box, have a variable instantly parse the input, and send that variable which contains the input text box string into a php switch statement through jquery. </p>

<p>The part from jquery to php works, but the part from transmitting a dynamic input text box into a variable for jquery doesn't. </p>

<p>Here's what i have:</p>

<pre><code>  &lt;script src="jquery-1.8.3.js"&gt;&lt;/script&gt;
   &lt;input id="in" type="text" onchange="myFunction()" /&gt;
   &lt;script&gt;
 function myFunction()
 {
  var a = document.getElementById("in");
  }
  // i am trying to make this var a equal to what is typed in the input box so that it can go into the "jsvar: a" part //
  $(document).ready(function(){

  $("button").click(function(){

  $.post("runphp.php", {  jsvar: a}, function(jsvar){ alert(jsvar);
     });
     });
     });
     &lt;/script&gt;
     &lt;button&gt;Run php switch statement with input&lt;/button&gt;
</code></pre>

<p>and the "runphp.php" file is simply a switch statement that works</p>

<pre><code>  &lt;?php 
   switch($_POST['jsvar'])
    {
     case "pass": 
      echo "&lt;3"; break;
     case "other stuff":
     echo "&lt;/3"; break;
      default:
     echo ":("; 
     }
    ?&gt;
</code></pre>

<p>The php part works fine.
 But the thing is, if i declare, for example, var a = "pass" instead of doing onchange &amp; myFunction(); then the jquery part works perfectly and passes on that value into jquery and into the php switch statement, yet when i try to make var a = that input box, it won't go through to php. I tried making an onchange function, but it still won't make var a equal to what i type in the input box so that it passes into the php switch statement through jquery. </p>
