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 8392687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:34:39+00:00 2026-06-09T19:34:39+00:00

I have a table that generates perfectly using php, ajax and the tablesorter plugin.

  • 0

I have a table that generates perfectly using php, ajax and the tablesorter plugin. I now would like to make a few of the input fields into dropdown boxes so the user can select an option if it needs to be changed. This all will then need to be saved to a database. Here is what I have so far:

    $('#getInfo').live('click', function() {
//clear table before search
    $("#inventoryUpdate tbody tr").remove();
    $('#messageInv').html('Please be patient, this might take a minute');
$.ajax({
    type: "POST",
    async: true,
    url: "getInventory.php",
    dataType: "json",
    data: ({skuStart: $("#startSkuRange").val(), skuEnd: $("#endSkuRange").val(), processDate: $("#processDate").val(),
           source: $("#source").val()}),
    success: function(data){
        $('#messageInv').hide(); 
        //console.log(data);
                    var myselectoptions = ''; 
        if(data.isbn2 === null){
                $("#inventoryUpdate").append('<tr><td>No Records Found</td></tr>');
            }else{
        for(var x=0;x<data.isbn2.length;x++)
                {
          $.each(data.defect2[x], function(index, val)
            {
             myselectoptions += '<option value="'+data.defect2[x][index].option+'">'+data.defect2[x][index].option+'</option>';
            });
        $("#inventoryUpdate").append('<tr><td id="tableSKU">'+data.sku[x]+'</td><td id="tableISBN">'+data.isbn2[x]+
                 '</td><td><input type="text" id="tableQuantity" value="'+data.quantity[x]+
                 '"/></td><td><select id="tableDefect">'+myselectoptions+
                 '"</select></td><td><input type="text" id="tableSource" value="'+data.source[x]+
                 '"/></td><td><input type="text" id="tableFeature" value="'+data.feature[x]+
                 '"/></td><td><input type="text"  id="tableLocation" value="'+data.location[x]+
                '"/></td><td><input type="text" id="tableProcessDate" value="'+data.processDate[x]+
                '"/></td><td><input type="text" id="tableBookType" value="'+data.booktype[x]+
                '"/></td><td><input type="text" id="tableCreatedBy" value="'+data.created[x]+
                '"/></td><td><input type="text" id="tableModifiedBy" value="'+data.modified[x]+
                '"/></td></tr>');
                                    }
        $("#inventoryUpdate").trigger("update");
            } // end of else statement
    } // end of success function
});// end of ajax call
}); // end of inventory update function

I would like to have the tableDefect and tableFeature inputs become drop down boxes that are populated dynamically, and default to the current info from the database. For example, if the defect from the database is “rip in dust jacket” that would be the option that is selected, but I also need the rest of the options (no defects, water damage etc.) from the database to be available if it needs to be changed. I would think that I need to change the input type to a select, but then how do I go about populating it? Would that require another call to the database for the information?
Is this even possible to do with this plug-in?
EDIT: I have pasted in the new code based on the answer below, I now am getting 19 “options” (it just says undefined not the actual value returned) for the first record, 38 for the second etc. There should only be 19 options.

  • 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-09T19:34:41+00:00Added an answer on June 9, 2026 at 7:34 pm

    If I am reading you correctly just replace <input type="text"......> with
    <select id=...><option>...</option></select>

    As far as populating the selects dynamically that can be handled a few different ways. With your ajax you would get the select values maybe by changing your existing

    data.defect[x] into a multidimensional object so instead of it being just a string you would output an array that will get converted to JSON on your backend so your object would look like

    defect[{"option":"value"},{"option":"value"},{"option":"value"},{"option":"value"}]

    Where when your building your table in the succession part you would loop over that object. You would essentially do the same as you do now.. except. your select would look like

    var myselectoptions = '';
       $.each(data.defect[x], function(index, val)
              {
                 myselectoptions += '<option value="'+data.source[x][index].option+'">'+data.source[x][index].option+'</option>';
              });
    '"/></td><td><select id="tableDefect">'+myselectoptions+'....
    

    now this is pure concept, I haven’t tested it, and its likely to need some tweaking to fit your needs specifically but this is the core concept of one of a few ways you can handle what you want done, that fits into what you are currently doing, without having to alter it too much.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some PHP code that generates dynamic tables of data on the fly.
I have a table that looks like this: id value AGA 0.211 AGA 0.433
I have a table that looks like this: CREATE TABLE foobar ( id SERIAL
I have a function that generates XML from a source. It works perfectly however,
have a table that dynamically generates text boxes in run time. I want to
I have an html table containing values that are being generated from javascript. How
I have an Entity Framework generated table with values in a td that I
I have table that I insert data with following query (from c# code): INSERT
I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45
I have a table that contains multiple dropdown menus for a list of profile

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.