Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2012
    Location
    Delhi
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Value not coming (showing object)

    Hi,
    i have written a code and want post happen within a loop but the values are not coming i suppose.

    $("#save").click(function ()
    {
    var i=1;
    while(i<=29)
    {
    var val_s=$("#slno_"+i);
    var val_a=$("#album_name_"+i);
    var val_p=$("#paper_used_"+i);
    var val_f=$("#finishing_"+i);
    var val_pr=$("#price_"+i);
    var val_v=$("#vat_"+i);
    var val_t=$("#total_amt_"+i);

    $.post("save_customer_price.php",{val_s:val_s,val_a:val_a,val_p:val_p,val_f:val_f,val_pr:val_pr,val_ v:val_v,val_t:val_t},
    function(data)
    {
    if(data=='Thanks For Registration!')
    {

    }
    else
    {
    alert(data);
    }
    });

    i++;
    }
    alert("Thanks For Registration!");
    });

    So can anyone check and reply will this code will work or any changes or suggestion to do this.

    Thanks

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,474
    Thanks
    13
    Thanked 361 Times in 357 Posts
    your experience is correct, $() will return a jQuery object. to get the value of an input field you would have to call the val() method.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •