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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:32:52+00:00 2026-06-11T14:32:52+00:00

I have a datatable with lots of rows. I need to add a new

  • 0

I have a datatable with lots of rows. I need to add a new row to the datatable (just client side, I want to use ajax to insert that new row in mysql). Most of the data I want to add in the columns are select-lists (which are retrived from mysql). My current add row function looks like this:

function fnAddRow() {       
var addData = {
    "sno": "<span id='txt'><img src='images/green_check.png' onClick='saveRow(this)';/><img src='images/red_cross.png' onClick='cancelEdit(this)';/></span>",       
    "project": "",
    "year": "<select name='year' id='year' ><option value='2012'>2012</option><option value='2013'>2013</option></select>",
};
oTable.fnAddData(addData); }

The data for ‘project’ should come from a mysql table. How do I add that? Please help!! Thanks in advance.

  • 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-11T14:32:53+00:00Added an answer on June 11, 2026 at 2:32 pm

    Try using ajax to get your project data as well:

    HTML:

    <input id="AddButton" type="button" />
    <table id="dataTable">
        ...
    </table>
    

    JavaScript:

    function fnGetProjectFromMySQL() {
        var projectHTML;
        $.ajax({
            url: "code/getMySQLData.php",
            success: function (mySqlData) {
                //Build your project html here using mySQLData
                projectHTML = "";
            }
        });
        return projectHTML;
    }
    
    function fnAddRow(oTable) {       
        var addData = {
            "sno": "<span id='txt'><img src='images/green_check.png' onClick='saveRow(this)';/><img src='images/red_cross.png' onClick='cancelEdit(this)';/></span>",       
            "project": fnGetProjectFromMySQL(),
            "year": "<select name='year' id='year' ><option value='2012'>2012</option><option value='2013'>2013</option></select>"
        };
        oTable.fnAddData(addData); 
    }
    
    $(document).ready(function () {
        var oTable = $("#dataTable").dataTable();
    
        $("#AddButton").click(function () {
            fnAddRow(oTable);
        });
    });
    

    I guess there are a few different ways to get this done. Google and javascript questions on stackoverflow should find you what you need:
    DataTables – How to add a row

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

Sidebar

Related Questions

I have DataTable in my application. It holds DataColumns and Rows. I just want
I have datatable with column name tag and 100 rows of data.I need to
I have datatable in vb.net 2008 has 40000 rows. i want to delete 1000
I have a DataTable which has 10 columns, and after I add some rows
I have a datatable with two columns. I want to store the rows of
I have a datatable customerTbl and I step through the rows foreach (DataRow row
I have a DataTable. I want to get every rows first column value and
I have a DataTable, say pdt, in my code. I just want to select
I have a datatable where the rows are dynamic and each row contain a
I have a Datatable in my C# program that I would like to INSERT

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.