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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:06:16+00:00 2026-06-12T06:06:16+00:00

I have a function (show below) that totals up all the hours on the

  • 0

I have a function (show below) that totals up all the hours on the page onBlur of the “.total” input fields. This function works perfectly in FF but in Chrome and Safari I am getting this error: SyntaxError: Unexpected EOF —I did some research but I am lost as to what might be causing this.

thanks for any help!

function totalUpHours() {
    //add all values to an array
    var hrsTotalsarr = new Array();
    $('.total').each(function() {
        var thisTotal = $(this).val();
        //clean the value
        if (thisTotal == "HRS") {
            thisTotal = 0;
        }
        hrsTotalsarr.push(thisTotal);
    });

    //sum up the array
    var hrsTotal = eval(hrsTotalsarr.join('+'));
    $('#taskHRStotals').val(hrsTotal);
}
  • 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-12T06:06:18+00:00Added an answer on June 12, 2026 at 6:06 am

    Sometimes invalid characters can work their way into code when you copy/paste code from websites.

    Unfortunately, they’re often invisible, and can only be noticed if you move your cursor across it with the arrow keys on your keyboard. When you get to the invalid one, the cursor will pause for a single keystroke.


    Aside from that, consider this alternative to using eval() in your code.

    function totalUpHours() {
    
        var hrsTotal = $('.total').map(function() {
                                         var thisTotal = $(this).val();
    
                                         return thisTotal == "HRS" ? 0 : thisTotal;
                                       })
                                  .toArray()
                                  .reduce(function(total, n) {
                                      return total + n;
                                  }, 0);
    
        $('#taskHRStotals').val(hrsTotal);
    }
    

    This is called map/reduce, and is a very handy pattern to know.

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

Sidebar

Related Questions

I have this tested function below that works fine for fading an element in
I have this function that checks if a page is the parent: function is_tree($pid)
I have this function below that takes a list of id's and searches the
I have a javascript function that will show the image you're about to upload
I have a function that need to sum up from each input but at
I have this handy snippet [see below] that truncates a set of list items
The form and script are show below and I appreciate all help on this.
I have the function below that validates the return of another function (function searchPlaces
I have this function: show_employee_table() -> do(qlc:q([B || B <- mnesia:table(employee)])). What it does
I have a function to show Dialog. public Dialog sendSMS(){ Dialog dialog = new

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.