title: Pass variable like an input id in Javascript
body: <p>Good day. I am still learning Javascript. And I have a function that is called by this button:</p>
  
  <pre><code>&lt;input class='inputButton' type='button' onclick="submit_data('EDIT')"&gt;
  </code></pre>
  
  <p>The function of submit_data looks like this:</p>
  
  <pre><code>function submit_data(mode){
  var txtName = $('#txtName').val();
  }
  </code></pre>
  
  <p>Where txtName is the id of a textbox. But suppose I have a variable called <code>$xDate</code> how do I call it?</p>
  
  <pre><code>var xDate =  $('$xDate').val();
  </code></pre>
  
  <p>like this?</p>
  
  <p>This is the whole submit_data:</p>
  
  <pre><code>function submit_data(mode){
  var txtName = $('#txtName').val();
  varUrl = "/includes/action.php";
  varData = "MODE=" + mode + "&amp;TXT_NAME=" + txtName;
  
       $.ajax({
            url: varUrl,
            type: 'POST',
            data: varData,
            success: function(result) {
                alert(result);
                if(result = 'success'){
                  redirect_to_parent();
                } 
                else
                {
                }
            }
       });
  }
  </code></pre>
  
  <p>And the action.php looks like this:</p>
  
  <pre><code>&lt;?php
  include_once("/includes/functions.php");
  
  $_GETVARS = (($_GET &lt;0) ? $_GET : $_POST);
  
  $mode = $_GETVARS['MODE'];
  switch ($mode){    
      case 'EDIT': 
  break;
  
      default:
          print_r($_GETVARS);
          break;
  }
  
  ?&gt;
  </code></pre>
  
  <p>In short. I need my variable to be accessible in action php. Possibly be included in my $_GETVARS</p>
  
  <p>Sorry for the confusion. $xDate is a variable. I cannot get it from textbox and exist only as a variable.</p>