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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:41:14+00:00 2026-05-12T08:41:14+00:00

Ok, considering the regular expressions aren’t working properly and there are no errors, I’m

  • 0

Ok, considering the regular expressions aren’t working properly and there are no errors, I’m going to try and use the money mask.

The goal is still to only allow numeric characters and a decimal. With maskMoney, that does the work for you.

Also, I need to be able to successfully calculate each cell.

As of right now, the masks are working good, but I’m no longer able to calculate. This is where I’m troubled.

JQuery and JavaScript code:


<script type="text/javascript" language="javascript">
    $(document).ready(function(){
     $('.date').mask("99/99/9999");
     $('.account').mask("99-9-999999-9999");
     /*calcuating the vertical and horizontal inputs*/

     $('.R26').attr("disabled", "disabled");

 $('.calc').maskMoney({symbol: ""});
 $('.R25').unmaskMoney();
 $('.R18').unmaskMoney();

 $('input.description').focus(function(){
  if($(this).val()=="Enter text here"){
   $(this).val(" ");
  }

  else{
   $(this).val($(this).val());
  }
 });
 $('input.description').blur(function(){
  if($(this).val()==" "){
   $(this).val("Enter text here");
  }    
 });

$('.calc').keyup(function(){
 var classArray = $(this).attr('class').split(' ');
 //Personal gas expense
 $('.gasamount').sum("change", "#totals4");
 var num = $(this).attr("id").replace(/[A-Za-z$,-]/g, "");
 $('#gasmoney'+num).val(<cfoutput>#mileage#</cfoutput> * $(this).val());
 $('.gasmoney').sum("change", "#totals5");
 //////////////////////

 //Sum of each cell
 $.each(classArray, function(){
  $('.'+this).sum("change", ".ttl"+this);
 });
 //Finding the grandtotal
 var grandTotal = $('.row26').parent().children('td:last').children('input');
 var sum = $('.row25').parent().children('td').children('.calc').sum();
 grandTotal.val(Number(sum).toFixed(2));
});

ColdFusion and HTML code:

#labels[r]#

<cfloop from="1" to="7" index="i">

 <td id="Day#i#" class="row#r# col#i#">
  <cfif r EQ 1>#Left(DayOfWeekAsString(i),3)#<cfelse><cfif r EQ 2>
  <input type="text" class="date-mask" /><cfelse>
  <input type="text" 
  <cfif labels[r] EQ "Personal Car: Mileage ##"> id="gasamount#i#" <cfelseif labels[r] EQ "Personal Car: Mileage $">id="gasmoney#i#" </cfif><cfif labels[r] EQ "Daily Totals">id="dailytotals#i#"</cfif>
   class="<cfif labels[r] EQ "Personal Car: Mileage ##">gasamount<cfelse><cfif labels[r] NEQ "Daily Totals">C#i#</cfif></cfif>
   <cfif labels[r] EQ "Personal Car: Mileage $">gasmoney<cfelse>calc R#r#</cfif>
   <cfif labels[r] EQ "Daily Totals">ttlC#i#</cfif>"
    <cfif labels[r] EQ "Daily Totals" OR labels[r] EQ "Personal Car: Mileage $">readonly="readonly"</cfif>
     /></cfif>
     </cfif>
 </td>


</cfloop>

 <td class="totals"><cfif r EQ 1>Total<cfelse><input type="text" id="totals" class="ttlR#r#" readonly="readonly" /></cfif></td>

I’ve had similar questions with the same application, but this is in fact not a duplicate(in case you think it is.).

The ‘.’+this is an object created by the array. I used cfloops to create a large table, and added multiple classes. Had to break up the multiple classes into an array, and then was able to select each class as its own.

  • 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-12T08:41:14+00:00Added an answer on May 12, 2026 at 8:41 am

    Ok. So I figured it out on my own.

    Using the maskMoney(), I am able to control what characters are entered and still able to correctly calculate the table.

    All I had to do to fix the calculations was to unmask the .gasamount:

                    $('.gasamount').unmaskMoney();
    

    This is what fixed the calculation problems. ^^ The mask was causing problems for the total of the 2 rows and those 2 rows caused the calculations to break.


                    $('.calc').maskMoney({symbol: ""});
                    $('.R25').unmaskMoney();
                    $('.R18').unmaskMoney();
    
                $('.calc').keyup(function(){
                    var classArray = $(this).attr('class').split(' ');
                    //Personal gas expense
                    $('.gasamount').sum("change", "#totals4");
                    var num = $(this).attr("id").replace(/[A-Za-z$,-]/g, "");
                    $('#gasmoney'+num).val(<cfoutput>#mileage#</cfoutput> * $(this).val());
                    $('.gasmoney').sum("change", "#totals5");
                    //////////////////////
    
                    //Sum of each cell
                    $.each(classArray, function(){
                        $('.'+this).sum("change", ".ttl"+this);
                    });
                    //Finding the grandtotal
                    var grandTotal = $('.row26').parent().children('td:last').children('input');
                    var sum = $('.row25').parent().children('td').children('.calc').sum();
                    grandTotal.val(Number(sum).toFixed(2));
                });
    

    Everyone that tried to help, thank you for taking the time!

    If anyone would like to use this example or the code for future applications, feel free to comment and let me know and I can setup a different page with an example and instructions and the source.

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

Sidebar

Related Questions

Good morning guys Is there a good way to use regular expression in C#
Considering the criteria listed below, which of Python, Groovy or Ruby would you use?
Considering there are so many draconian firewalls in the world, is there any reason
I am completely new to regular expressions so I'm looking for a bit of
I know that using Regular expressions to parse or manipulate HTML/XML is a bad
Considering such code: class ToBeTested { public: void doForEach() { for (vector<Contained>::iterator it =
Considering private is the default access modifier for class Members, why is the keyword
Considering this code, can I be absolutely sure that the finally block always executes,
Considering the following architecture: a base object 'Entity' a derived object 'Entry:Base' and a
Considering a large system with hundreds of assemblies, what is the easiest way to

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.