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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:22:23+00:00 2026-06-06T18:22:23+00:00

Im getting 2 values from a table and I’d like to compare them. If

  • 0

Im getting 2 values from a table and I’d like to compare them. If one is grater than the other, then I alert some error.
The thing is im getting a wrong result… for example I have 1000.00 and 1000000.00 and when I do 1000.00 > 1000000.00 Im getting a TRUE!, therefore an error, Why is that happening?

Hope someone can help me out here! Thx

row = document.getElementById(tabla).rows;
cell = document.getElementById(tabla).rows[0].cells;

for (i=2;i<row.length-1;i++){
    var TotalDist = parseFloat(document.getElementById(tabla).rows[i].cells[cell.length].firstChild.nodeValue).toFixed(2);
    var Total = document.getElementById(tabla).rows[i].cells[cell.length+1].firstChild.nodeValue;

    if(TotalDist>Total)
       alert("Error");
}

One of the values is already a float that I get from a db, the other one (TotalDist) is set by the user, so I convert it to float so that they can be compared properly… but it doesnt seem to be working

  • 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-06T18:22:25+00:00Added an answer on June 6, 2026 at 6:22 pm

    You need to convert both values to a number (ie use parseFloat on both strings) ->

    row = document.getElementById(tabla).rows;
    cell = document.getElementById(tabla).rows[0].cells;
    
    for (i=2;i<row.length-1;i++){
        var TotalDist = parseFloat(document.getElementById(tabla).rows[i].cells[cell.length].firstChild.nodeValue).toFixed(2);
        var Total = parseFloat(document.getElementById(tabla).rows[i].cells[cell.length+1].firstChild.nodeValue);
    
        if(TotalDist>Total)
           alert("Error");
    
    }
    

    When using nodeValue a string is returned … see the docs

    var value = node.nodeValue;
    

    value is a string containing the value of the current node

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

Sidebar

Related Questions

Basically, I'd like to insert into table, getting values id from the same table,something
So, I'm getting a bunch of string values from a JSON object and then
So I've been getting some mysterious uninitialized values message from valgrind and it's been
i getting values from query I'm looking for output like this: Please help me
In the SQL Server, I am trying to insert values from one table to
In SQL server, I am trying to insert values from one table to another
I would like to execute the below query by passing some values from applet
I'm trying to string concatenate multiple row values from one table using Coalesce, separated
When getting all values from db table, I get this error on the last
I'm currently getting top rated articles by summing vote values from 'votes' table against

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.