Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get value after changing input value with jQuery?

Tags:

jquery

This is my script that after changing input value should send it to php file with Ajax.But it's sending the actual value from input field which is set via php.How can i set the new value to be given?

var idg;
var newg;

$('input.readonly').live("click",
    function() {
    $(this).attr('readonly', false);
    idgs=$(this).attr('id');
    newg=$(this).attr('value');

    $(this).change(function(){
        $.ajax({
          type:'POST',
          url: 'new.php',
          data: "idgs="+ idgs +"&newg="+ newg,
          success: function(data) { $('.right').html(data); }
        });
    })
}); 
like image 514
Lyubo Avatar asked Jun 13 '26 16:06

Lyubo


2 Answers

$(this).change(function(){
 $.ajax({
      type:'POST',
      url: 'new.php',
      data: "idgs="+ idgs +"&newg="+ $(this).val(),
      success: function(data) {
        $('.right').html(data);

      }
    });
});
like image 114
Chamika Sandamal Avatar answered Jun 16 '26 08:06

Chamika Sandamal


var idg;
var newg;
$('input.readonly').live("click", function(){

    $(this).attr('readonly', false);

    $(this).change(function(){
        idgs=$(this).attr('id');
        newg=$(this).val();
        $.ajax({
            type:'POST',
            url: 'new.php',
            data: "idgs="+ idgs +"&newg="+ newg,
            success: function(data) {
                $('.right').html(data);
            }
        });

    })

}); 

This should do it, you where filling idg and newg with the default values, before they changed.

like image 35
Frederick Behrends Avatar answered Jun 16 '26 08:06

Frederick Behrends



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!