title: How do I pass value from Jquery to PHP ? HTML is a hidden input form field
body: <p>I have a form:</p>
  
  <pre><code>&lt;form action="post.php" method="POST"&gt;
   &lt;p class="select1"&gt;Northern Cape&lt;/p&gt;
   &lt;p class="select1"&gt;Eastern Cape&lt;/p&gt;
  
   &lt;p class="select2" &gt;New Goods&lt;/p&gt;
   &lt;p class="select2" &gt;Used Goods&lt;/p&gt;
  
  &lt;input id="submt" type="submit" name="submit" value="Submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>JQUERY .... appends input/value to the selected items:</p>
  
  <pre><code>$(document).ready(function() {
      $('.select1').click(function() {    
        if ($(this).text() == "Northern Cape"){
            $(this).append("&lt;input id='firstloc' type='hidden' name='province' 
            value='Northern Cape' /&gt;");
            $("#firstloc").val('Northern Cape');
       }; // end of if statement
  
        if ($(this).text() == "Eastern Cape"){
            $(this).append("&lt;input id='firstloc' type='hidden' name='province' 
            value='Eastern Cape' /&gt;");
            $("#firstloc").val('Eastern Cape');
       }; // end of if statement
  }); // end of click function
  }); // end of document ready
  
   $(document).ready(function() {
      $('.select2').click(function() {
          if ($(this).text() == "New Goods"){
              $(this).append("&lt;input id='category' type='hidden' name='cat' 
              value='New Goods' /&gt;");
              $(this).val('New Goods');
           };
  
          if ($(this).text() == "Used Goods"){
              $(this).append("&lt;input id='category' type='hidden' name='cat' 
              value='Used Goods' /&gt;");
              $("#category").val('Used Goods');
           };
  
  });
  });
  </code></pre>
  
  <p>How do I pass the values to PHP ie. first value Province second value Category?</p>
  
  <pre><code>&lt;?php
  
  $province = $_POST['province'];
  $category = $_POST['cat'];
  echo $province;
  echo $category;
  ?&gt;
  </code></pre>
  
  <p>I get a message Undefined index:cat when passing to PHP. 
  User must select 2 items and values must be passed to PHP,I do not want to use a drop down menu with "options"  </p>