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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:07:15+00:00 2026-06-18T02:07:15+00:00

I am looking for a way to make html table acting like excel using

  • 0

I am looking for a way to make html table acting like excel using Javascript (Jquery preferred). Here are my problem. I made a table like this:

 <table>
       <tr>
          <td id="A1">10</td>
          <td id="B1">10.5</td>
       </tr>
       <tr>
          <td id="A2">5</td>
          <td id="B2" formula="A1+B1+A2"></td>
       </tr>
 </table>

Every td has an id, some of those tds are added a formula attribute. And I wanna to calculate those formula, give the value of formula to the td.

In the table above, here, I wanna assign the B2 value 25.5(B2=A1+B1+A2).

Look like this:

<td id="B2" formula="A1+B1+A2">25.5</td>

Can anybody give me a clue? Thanks.

PS: Here are some resource that I found, but they do not solve my problem

  1. Spreadsheet-like formulas on the DOM

  2. http://zaach.github.com/jison/docs/


Thanks a lot @palindrom. I finally solved my problem based on your answer.

Here is my code:

    $("td[formula]").each(function(){
        //1 get formula attribute
        var formula = $(this).attr('formula');

        //2 use regex to make expression, with the surpport of "A122", "AB1" and more
        var expression = formula.replace(/([A-Z]+[0-9]+)/g, "parseFloat(\$('#$1').html())") ;

        //3 eval the expression
        var result = eval( expression );

        //4 set the value
        $(this).html(result);
     });
  • 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-18T02:07:16+00:00Added an answer on June 18, 2026 at 2:07 am

    Should work for simple math, didnt try:

    $("td[formula]").each( function() {
      this.html( eval( this.attr("formula").replace(/[a-z][0-9]/g, "\$('#$0').html()") ) );
    } );
    

    Edit:
    If you have functions like sum in the formulas, implement them as javascript functions and they should work too.

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

Sidebar

Related Questions

I am looking for a way to make an AJAX load request in javascript,
I'm currently looking for a way to make node.js-API-calls from static html. I've looked
I'm looking for a way to make specific elements in a HTML rich text
I'm looking for a way to make semi-transparent form elements in HTML. I know
Im looking for a way to make a top bar consistent across activities, allmost
I'm looking for a way to make the search/replace function of VS IDE regex-aware,
I'm looking for a way to make it easy for technically unsophisticated users to
I am looking for a way to make my own login formular in PHP
I am looking for a way to make a request to an XML service
I'm looking for a way to make word-wrap in PHP a bit smarter. So

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.