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

  • Home
  • SEARCH
  • 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 8815379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:21:43+00:00 2026-06-14T04:21:43+00:00

I have the following div that contains the table and its data queried from

  • 0

I have the following div that contains the table and its data queried from database

<div id="content">
<table>
<tbody>
   <tr>
       <th class="header" colspan="2">Food items include:</th>
   </tr>
   <tr>
      <td id="15" class="fruits">Papaya+salt</td>
      <td><p>This includes papaya and salt</p></td>
   </tr>
   <tr>
      <td class="meat">Baked chicken</td>
      <td><p>This includes a chicken thide and kethup</p></td>
   </tr>
   <tr>
      <td id="1" class="Juices">Strawberry Sting</td>
      <td><p>Sugar, color and water</p></td>
   </tr>
<table>
</div>

That table is defined in a page.aspx

and here is my code used to sort that table data alphabetically

OldFunc = window.onload;
window.onload = OnLoad;

function OnLoad(){
    try{
        var pathName = window.location.pathname.toLowerCase();
        if( pathName=="/Resources/Glossary.aspx") {
                sort_it();
            }   
        OldFunc();
    }
    catch(e) {
    }
} 

function TermDefinition(def_term,def_desc)
{    
    this.def_term=def_term;  
    this.def_desc=def_desc; 
}    

function sort_it()
{
    var gloss_list=document.getElementsByTagName('td');    
    var desc_list=document.getElementsByTagName('td p');    
    var gloss_defs=[];   
    var list_length=gloss_list.length;     
    for(var i=0;i<list_length;i++)    
    {      
       gloss_defs[i]=new TermDefinition(gloss_list[i].firstChild.nodeValue,desc_list[i].firstChild.nodeValue);      
    }     
    gloss_defs.sort(function(a, b){
      var termA=a.def_term.toLocaleUpperCase(); 
      var termB=b.def_term.toLocaleUpperCase();
      if (termA < termB) 
       return -1;
      if (termA > termB)
       return 1;
      return 0; 
    })    
    for(var i=0;i<gloss_defs.length;i++)
    {
       gloss_list[i].firstChild.nodeValue=gloss_defs[i].def_term;
       desc_list[i].firstChild.nodeValue=gloss_defs[i].def_desc;  
    }
}

Please lookat the the two getElementsByTagName, I think I am misuse its content since nothing is done on the output.

  • 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-14T04:21:44+00:00Added an answer on June 14, 2026 at 4:21 am

    Invalid:

    desc_list=document.getElementsByTagName('td p');
    

    You can’t pass a css selector to that function, only a tag name like div\ span input etc’.

    You might want to use:

    desc_list = $('td p');
    

    Since you tagged the question with jQuery, or document.querySelectorAll for vanilla js:

    desc_list = document.querySelectorAll('td p');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following markup <div id=hearingSummary> <table class=minitable> ... content removed for brevity
I have the following html. Its a table that can contains many rows id=rows_x.
I have the following mark up of a div that contains a form. The
So I have some html that looks like the following: <div class='something unknown' id='something_unknown_1'>
I have the following sql query that fetches images from an establishment table. The
In HTML, I have a div that contains a table of labels and textboxes
i have the following problem with that code in my html tag: <div id=searchbar><input
I have the following function that I only want to run inside <div id=imgWrapper>
I have a single .html file that looks similar to the following: <div id=myPage
I have a following div structure <div id=wrapper> <div id=header> <div id=storeFinder> /* html

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.