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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:53:19+00:00 2026-05-16T16:53:19+00:00

I’m trying to create to use a table as a look-up table. Normally, I

  • 0

I’m trying to create to use a table as a look-up table. Normally, I would do this server side, but in this case I just have an html table and the table is going to be inputted by the client.

Basically, when filling out a form they give me two values which are in columns A & B. Then the form needs to do a calculation using the corresponding value in Column C. Column A is repeated multiple times, rather then entering it multiple times, the rowspan attribute is used, which seems to be really complicating this, but it would be a big deal to change (it might be possible, but I’d rather avoid).

A simplified version:

<table>
  <thead>
    <tr><th>Column A</th><th>Column B</th><th>Column C</th></tr>
  </thead>
  <tbody>
    <tr>
      <td rowspan="3">val1</td>
      <td>1</td>
      <td>2</td>
    </tr>
    <tr>
      <td>2</td>
      <td>2</td>
    </tr>
    <tr>
      <td>2</td>
      <td>3</td>     
    </tr>
    <tr>
      <td rowspan="2">val2</td>
      <td>4</td>
      <td>5</td>
    </tr>
    <tr>
      <td>10</td>
      <td>15</td>
    </tr>
  </tbody>
</table>

So if they input:
val1 and 1 -> 2
val2 and 4 -> 5
val2 and 10 -> 15

The one idea I have is to first parse the table into a nested array and then use it. It appears to work, but I wanted to get others opinion on the best way to handle this. If I could just query/filter based on the DOM it seems like it would use less memory, but again the rowspan attribute seems to make those solutions ugly.

Edit: correct having the second rowspan attribute on the tr tag instead of the td tags
Edit: tried clarifying via the example section that you could potentially look up any row

  • 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-05-16T16:53:20+00:00Added an answer on May 16, 2026 at 4:53 pm

    I think the best way (other than working w/ the form data server side) would be to use jQuery to work with the form data directly before it’s submitted rather than working with the HTML result.

    But if you have no control over that, this will bring the first row for each “val#” rowspan’s “C” column value into an object keyed by each “val#” string where you can work with it (via a for in loop for example). You should add an “id” attribute (eg: id=”myTable”) to your table tag because that will optimize the jQuery selector.

    
    $(window).ready(function() {
      var vals = {}, $table = $('#myTable');
    
      $table.find('td[rowspan]').each(function(i,e) {
        $(e).siblings().each(function(j,s) {
          var html = e.innerHTML, key = (html.match(/^[a-z0-9]+$/)) ? html : i.toString();
    
          vals[key] = parseInt($(s).html(), 10);
        });
      });
    
      for(var val in vals) {
        if(!vals[val]) continue;
    
        vals[val] = vals[val] + 20;
    
        alert(vals[val]); // alerts 22, then 25
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to create an if statement in PHP that prevents a single post

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.