title: onClick event that will save the clicked Anchor's name using PHP-Codeigniter
body: <p>I have a 4 links, and each time I click one of them it will auto increment the value of the priority number here's the code for that</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id ="qnum" style = "text-align: center; font-size: 5em; margin-top: 0px"&gt;&lt;/div&gt;
  &lt;div class = "container" style = "text-align: center; margin-top: 100px;"&gt;
  &lt;form id="getTicketForm" name="getTicketForm" method="post" action=""&gt;
      &lt;input type="text" name="hiddenqnum" id="hiddenqnum" value=""&gt;
      &lt;a href="#" onClick="getPnumber()" style = "font-size: 3em;" name = "transaction" value = "payment" id = "payment"&gt;Payment&lt;/a&gt;&lt;br /&gt;
      &lt;a href="#" onClick="getPnumber()" style = "font-size: 3em;" name = "transaction" value = "landtax" id = "landtax"&gt;Land Tax&lt;/a&gt;&lt;br /&gt;
      &lt;a href="#" onClick="getPnumber()" style = "font-size: 3em;" name = "transaction" value = "spl" id = "spl"&gt;Special Lane&lt;/a&gt;&lt;br /&gt;
      &lt;a href="#" onClick="getPnumber()" style = "font-size: 3em;" name = "transaction" value = "bpld" id = "bpld"&gt;BPLD&lt;/a&gt;&lt;br /&gt;
      &lt;/form&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>and this is the function getPnumber()</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;script type="text/javascript"&gt;
  //display Priority Number
      var num = 1;
      var queue = ('0000'+num).slice(-4);;
      document.getElementById("qnum").innerHTML = "Your Priority Number is" +  "&lt;br&gt;" + queue;
  //if button is clicked, queue will increment
      function getPnumber() {
          num += 1;
          var queue = ('0000'+num).slice(-4);;
          document.getElementById("qnum").innerHTML = "Your Priority Number is" + "&lt;br&gt;" + queue;
  
          
          document.getTicketForm.hiddenqnum.value = queue;
         
      };
  
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  
  i have no problem in that part, but i want also to save the link's value &amp; priority number into database
  here's my script,</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function save(){
  
  $(document.ready)(function(){
      $('#getTicketForm').click(function(){
          var qnumber = $("input[name=hiddenqnum]").val();
          var transaction = $().val();
       
              $.ajax({
                  url:'&lt;?php echo base_url(); ?&gt;main/queue',
                  type: 'POST',
                  data: {
                      qnumber : qnumber,
                      transaction : transaction
                  },
                  success : function(data){
                      console log.(data);
                  }
              })
      });
  });
  };
  
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>and later i will change my link's onclick into  function Onclick()
  which is</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;script&gt;
  function onClick(){
   getPnumber();
   save();
  };
  &lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>i hope you could help me in saving the links value and priority while it still auto increments after clicking.
  by the way i am using php-codeigniter
  anyway my issue is my function save() i can't save to my DB, i also have a problem in getting the priority number from hidden text and pass it to var qnumber</p>