Take last result and increment with php, javascript and mysql

Asked

Viewed 73 times

-1

As I do to take the last value inserted in SPAN and add another 10 to save in BD, the insertion is all ok, I need to delete the input and each time BD add another 10. Example: Product 100 by clicking the button, Product 110 so on, no refresh 1 cent auction site type. I built this script below and this worked insertion, but client puts the value you want, I need to delete the input and add the values by clicking the button Personal Thank you.....

<script>
$(document).ready(function(){
 $('#load_button').click(function(){
  var valor_txt = $('#valor').val(); 
  if($.trim(valor_txt) != '')
  {
   $.ajax({
    url:"produtos/insert.php",
    method:"POST",
    data:{arremate:valor_txt},
    dataType:"text",
    success:function(data)
    {
     $('#valor').val("");
    }
   });
  }
 });
 
 setInterval(function(){
  $('#load_price').load("produtos/arremate.php").fadeIn("slow");
}, 1000);
 
});
</script>
<input type="text" name="valor" id="valor" class="form-control" /> <!-- envia valor para o DB -->
<input type="button" name="load_button" id="load_button"  value="valor" class="btn btn-info" />

<span class="item_price" name="load_price" id="load_price"></span> 

1 answer

-1

You could remove the input using javascript when clicking.


Element.prototype.remove = function() {
    this.parentElement.removeChild(this);
}
NodeList.prototype.remove = HTMLCollection.prototype.remove = function() {
    for(var i = this.length - 1; i >= 0; i--) {
        if(this[i] && this[i].parentElement) {
            this[i].parentElement.removeChild(this[i]);
        }
    }
}
// Use no evento
function my() {
  var parent = document.getElementById("valor").remove();
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.