Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9026387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:30:25+00:00 2026-06-16T06:30:25+00:00

success: function (output) { var obj = $.parseJSON(output); $(#existcustomers).empty(); for (var iCnt = 0;

  • 0
success: function (output) {

    var obj = $.parseJSON(output);

    $("#existcustomers").empty();


    for (var iCnt = 0; iCnt < obj.length; iCnt++) {

        if (obj[iCnt].firstname == null) { obj[iCnt].firstname = ""; }
        if (obj[iCnt].lastname == null) { obj[iCnt].lastname = ""; }
        if (obj[iCnt].address1 == null) { obj[iCnt].address1 = ""; }
        if (obj[iCnt].address2 == null) { obj[iCnt].address2 = ""; }
        if (obj[iCnt].city == null) { obj[iCnt].city = ""; }
        if (obj[iCnt].state == null) { obj[iCnt].state = ""; }
        if (obj[iCnt].zip == null) { obj[iCnt].zip = ""; }
        if (obj[iCnt].phone == null) { obj[iCnt].phone = ""; }
        if (obj[iCnt].email == null) { obj[iCnt].email = ""; }
        if (obj[iCnt].cell == null) { obj[iCnt].cell = ""; }

        var newRow = $("<tr><td>" + obj[iCnt].firstname + "</td><td>" + obj[iCnt].lastname + "</td><td>" + obj[iCnt].address1 + "</td><td>" + obj[iCnt].address2 + "</td><td>" + obj[iCnt].city + "</td><td>" + obj[iCnt].state + "</td><td>" + obj[iCnt].zip + "</td><td>" + obj[iCnt].phone + "</td><td>" + obj[iCnt].email + "</td><td>" + obj[iCnt].cell + "</td></tr>");
        $("#existcustomers").append(newRow);
    }



    $("#existcustomers tr").hover(function () { $(this).addClass("highlight"); }, function () { $(this).removeClass("highlight"); });

    $("#existcustomers tr").click(function () {

        $("input#firstname").val($(this).children(":eq(0)").text());
        $("input#lastname").val($(this).children(":eq(1)").text());
        $("input#address1").val($(this).children(":eq(2)").text());
        $("input#address2").val($(this).children(":eq(3)").text());
        $("input#city").val($(this).children(":eq(4)").text());
        $("input#state").val($(this).children(":eq(5)").text());
        $("input#zip").val($(this).children(":eq(6)").text());
        $("input#phone").val($(this).children(":eq(7)").text());
        $("input#email").val($(this).children(":eq(8)").text());
        $("input#cell").val($(this).children(":eq(9)").text());

        $("input#firstname").attr('disabled', 'disabled');
        $("input#lastname").attr('disabled', 'disabled');
        $("input#address1").attr('disabled', 'disabled');
        $("input#address2").attr('disabled', 'disabled');
        $("input#city").attr('disabled', 'disabled');
        $("input#state").attr('disabled', 'disabled');
        $("input#zip").attr('disabled', 'disabled');
        $("input#phone").attr('disabled', 'disabled');
        $("input#email").attr('disabled', 'disabled');
        $("input#cell").attr('disabled', 'disabled');

        //Here a commit to session script for the current customer will
        // be aded. 

        //end 

        $('#form-main').css('background-color', 'green');
    });
}

I have the code above which is a return from an ajax. There is a bunch of JSON in ‘obj’ and my code loops through each “row” of the JSON and uses jQuery to append the “row” data to a table by way of .append(). I would like to take things a step further and store with .data() a key value pair for the ID of each row. The JSON contains a field ID which is an auto incremented primary key. I am trying to store that field from the JSON in each row with .data() for later retrieval by another call to ‘.ajax’. I am sure there are many of you out there that would have a much better mental picture of how to accomplish the goal so I mean to get some suggestions. I hope that is alright.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T06:30:27+00:00Added an answer on June 16, 2026 at 6:30 am

    You can add data to your new row when you create it as follows

     var newRow = $("<tr>......</tr>").data('id',value);
    

    Then later to access it:

    $("#existcustomers tr").click(function(){
       var rowId=$(this).data('id');
    
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function checkSession(){ $.ajax({url: session.php, success: function(data){ if( data == 1){ var postFilen = 'msg.php';
function checkuser(user) { var ret = false; $.ajax({ type:'POST', url:'user.php', async:false, data:{'user':user}, success:function (data)
Can someone tell me why this alert is empty? var pending_dates = []; $.getJSON('/ajax/event-json-output.php',
flagUpdateCustomer = 0; $(input#checknames).click(function () { $.ajax({ url: 'php.scripts/checknames.php', data: { firstname: $(input#firstname).val(), lastname:
I have an ajax function: $.ajax({ url: 'http://localhost/process.php', type: 'post', data: '', success: function(output)
I have an jquery ajax success function which uses a template to put json
jQuery code: function ajaxsubmit(){ $.ajax({ url: /update, type: POST, dataType: html }).success(function(data) { $('#result').html(data);
Having issues referencing $(this) from within a the nested ajax 'success' function... I know
It seems that i cannot access $(this) inside jquery ajax success function. please see
I would like to get the url from a jQuery success function, after it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.