Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Please help with this script mod.

Posted on 2004-09-10
8
145 Views
Last Modified: 2011-09-20
I have this script that took forever for me and others here to develop, however I need to modify it.

I need to recalculate totalcost in a differnt maner if tablecount is defined.

here is what the calculation is for the total cost if table count is difined > 0

totalcost = if 1 table =800
if 2 tables = 500
if 3 tables then 700

if the tablecount is defined then all other calculation are nixed with the exceptions of converting the total cost to words which I have also included below.

your help is always greatfully appreciated.


\\performs calculations for form
function CheckForm(){
var today = new Date(today)
var bl = (document.boothinformation.BT_B1_Dim_1.value);
var bw = (document.boothinformation.BT_B1_Dim_2.value);
var columns = (document.boothinformation.BT_Post.value);
var ismember = (document.boothinformation.BT_Member.value);
var corners = (document.boothinformation.BT_Corners.value);
var deposit = (document.boothinformation.BT_Deposit.value);
var contractDate = (document.boothinformation.BT_ContractDate.value);
var compstate = (document.boothinformation.compstate.value);
var country = (document.boothinformation.country.value);
var cancelled = (document.boothinformation.BT_Cancelled.value);
var cancelledDate = (document.boothinformation.BT_CancelledDate.value);
var cdstat = (document.boothinformation.bt_CD_Status.value);
var cddate = (document.boothinformation.BT_cd_Date.value);
var manstat = (document.boothinformation.bt_Manual_Status.value);
var mandate = (document.boothinformation.BT_ManualDate.value);
var fpr = (document.boothinformation.BT_FPR.value);
var fprDate = (document.boothinformation.BT_FPRDate.value);
var DepositDate = (document.boothinformation.BT_DepositDate.value);
<!--- added to support vendors jr 09092004 --->
var Tassign = (document.boothinformation.tableassign.value);
var Tcount = (document.boothinformation.tablecount.value);
<!--- var testdate = (document.boothinformation.OutDate.value); --->
var moy = today.getMonth() + 1;

//does the arithmatic for the total sq ft.
///changed to "must have non zero value" (not a NAN either)
if((bl >0) && (bw >0) || columns>0){
     var columnsqft = (columns * 5);
   if(bl<1 || bw<1)
     {  var totalsqft = (document.boothinformation.BT_TotalSQFT.value - (columnsqft));
    }
    else     {
var totalsqft = ((bl*bw) - (columnsqft));    
}
     document.boothinformation.BT_TotalSQFT.value = totalsqft;
      }
   
      
//calculates member and non member cost
totalsqft=document.boothinformation.BT_TotalSQFT.value
     if (ismember == 1){
          var totalcost = ((totalsqft * 10) + (corners * 200));
          var memdiscount = (totalsqft);
     }
      if (ismember == 0)       {
          var totalcost = ((totalsqft * 11) + (corners * 200));
          var memdiscount = (0);
     }
     
      
     document.boothinformation.BT_TotalCost.value = totalcost;
     document.boothinformation.BT_MemberD.value = memdiscount;
if (compstate == 'NA')
{
 document.boothinformation.BT_TotalCost.value = totalcost;
    }
if (compstate != 'NA')
{
 document.boothinformation.BT_TotalCost.value = (0);
 }
      
        
            <!--- calculate all with under the month of august the country =usa --->
if ((totalsqft >= 301))
        {
document.boothinformation.BT_FPR.value = (0);
document.boothinformation.BT_FPRDate.value = ('');
                   document.boothinformation.BT_Deposit.value = ((totalcost) * .25);
document.boothinformation.BT_DepositDate.value = (setNewDate(document.boothinformation.BT_ContractDate.value));
     }
      
      
        if ((totalsqft <= 300 ))
{
document.boothinformation.BT_FPR.value = (1);
document.boothinformation.BT_FPRDate.value = (setNewDate(document.boothinformation.BT_ContractDate.value));

document.boothinformation.BT_Deposit.value = (0);
document.boothinformation.BT_DepositDate.value = ('');
     }
      

      
       if  (moy>=9)
       {
document.boothinformation.BT_FPR.value = (1);
document.boothinformation.BT_FPRDate.value = (setNewDate(document.boothinformation.BT_ContractDate.value));
document.boothinformation.BT_Deposit.value = (0);
document.boothinformation.BT_DepositDate.value = ('');
     }
      
 if (((country != 'USA') ) && ((country != 'Canada')))
       {
document.boothinformation.BT_FPR.value = (1);
document.boothinformation.BT_FPRDate.value = (setNewDate(document.boothinformation.BT_ContractDate.value));
document.boothinformation.BT_Deposit.value = (0);
document.boothinformation.BT_DepositDate.value = ('');
     }
      
      
}



-->
</SCRIPT>
0
Comment
Question by:jriver12
  • 4
  • 3
8 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 12025906
Ask the Community Support to delete one of the questions and put in the one question where you like to continue the COMPLETTE page for analyzis and extension.
As long as nobody comments in your question in JavaScript TA you can delete that question on your own.

0
 
LVL 19

Accepted Solution

by:
dakyd earned 500 total points
ID: 12026913
I'm not entirely sure I follow, but I gave it a shot.  If Tcount > 0, then the variable totalcost is set based on your specification and no member discount is set.  Otherwise, totalcost & member discount are calculated as before.  Hopefully that'll help, but if that's not what you want, then could you clarify what you're trying to do (it might also help to post the HTML source of the page you're working with)?

\\performs calculations for form
function CheckForm(){
var today = new Date(today)
var bl = (document.boothinformation.BT_B1_Dim_1.value);
var bw = (document.boothinformation.BT_B1_Dim_2.value);
var columns = (document.boothinformation.BT_Post.value);
var ismember = (document.boothinformation.BT_Member.value);
var corners = (document.boothinformation.BT_Corners.value);
var deposit = (document.boothinformation.BT_Deposit.value);
var contractDate = (document.boothinformation.BT_ContractDate.value);
var compstate = (document.boothinformation.compstate.value);
var country = (document.boothinformation.country.value);
var cancelled = (document.boothinformation.BT_Cancelled.value);
var cancelledDate = (document.boothinformation.BT_CancelledDate.value);
var cdstat = (document.boothinformation.bt_CD_Status.value);
var cddate = (document.boothinformation.BT_cd_Date.value);
var manstat = (document.boothinformation.bt_Manual_Status.value);
var mandate = (document.boothinformation.BT_ManualDate.value);
var fpr = (document.boothinformation.BT_FPR.value);
var fprDate = (document.boothinformation.BT_FPRDate.value);
var DepositDate = (document.boothinformation.BT_DepositDate.value);
<!--- added to support vendors jr 09092004 --->
var Tassign = (document.boothinformation.tableassign.value);
var Tcount = parseInt(document.boothinformation.tablecount.value);
<!--- var testdate = (document.boothinformation.OutDate.value); --->
var moy = today.getMonth() + 1;

// does the arithmatic for the total sq ft.
// changed to "must have non zero value" (not a NAN either)
if((bl >0) && (bw >0) || columns>0){
     var columnsqft = (columns * 5);
   if(bl<1 || bw<1)
     {  var totalsqft = (document.boothinformation.BT_TotalSQFT.value - (columnsqft));
    }
    else     {
var totalsqft = ((bl*bw) - (columnsqft));    
}
     document.boothinformation.BT_TotalSQFT.value = totalsqft;
      }
   
     
// calculates member and non member cost
totalsqft=document.boothinformation.BT_TotalSQFT.value;
if (Tcount <= 0)
{
     if (ismember == 1){
          var totalcost = ((totalsqft * 10) + (corners * 200));
          var memdiscount = (totalsqft);
     }
      if (ismember == 0)      {
          var totalcost = ((totalsqft * 11) + (corners * 200));
          var memdiscount = (0);
     }
     document.boothinformation.BT_MemberD.value = memdiscount;
}
else
{
    switch(Tcount)
    {
      case 1:
        var totalcost = 800;
        break;
      case 2:
        var totalcost = 500;
        break;
      case 3:
        var totalcost = 700;
        break;
    }
}
 
     document.boothinformation.BT_TotalCost.value = totalcost;
if (compstate == 'NA')
{
 document.boothinformation.BT_TotalCost.value = totalcost;
    }
if (compstate != 'NA')
{
 document.boothinformation.BT_TotalCost.value = (0);
 }
     
       
          <!--- calculate all with under the month of august the country =usa --->
if ((totalsqft >= 301))
       {
document.boothinformation.BT_FPR.value = (0);
document.boothinformation.BT_FPRDate.value = ('');
                  document.boothinformation.BT_Deposit.value = ((totalcost) * .25);
document.boothinformation.BT_DepositDate.value = (setNewDate(document.boothinformation.BT_ContractDate.value));
     }
     
     
       if ((totalsqft <= 300 ))
{
document.boothinformation.BT_FPR.value = (1);
document.boothinformation.BT_FPRDate.value = (setNewDate(document.boothinformation.BT_ContractDate.value));

document.boothinformation.BT_Deposit.value = (0);
document.boothinformation.BT_DepositDate.value = ('');
     }
     

     
      if  (moy>=9)
      {
document.boothinformation.BT_FPR.value = (1);
document.boothinformation.BT_FPRDate.value = (setNewDate(document.boothinformation.BT_ContractDate.value));
document.boothinformation.BT_Deposit.value = (0);
document.boothinformation.BT_DepositDate.value = ('');
     }
     
if (((country != 'USA') ) && ((country != 'Canada')))
      {
document.boothinformation.BT_FPR.value = (1);
document.boothinformation.BT_FPRDate.value = (setNewDate(document.boothinformation.BT_ContractDate.value));
document.boothinformation.BT_Deposit.value = (0);
document.boothinformation.BT_DepositDate.value = ('');
     }    
}

-->
</SCRIPT>
0
 

Author Comment

by:jriver12
ID: 12027583
dakyd,
I am getting a undifined error in the totalcost form.field.
I would be glad to send you the code. I dont think that it would be greatly appreciated by the comm if I posted 1100 lines of code on this thread.
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 19

Expert Comment

by:dakyd
ID: 12028705
Is it available online anywhere?  A link would be just as good.  If not, my email address is in my profile, and I'll take a look at it.
0
 

Author Comment

by:jriver12
ID: 12046102
I sent it this morn, did you receive it.
0
 
LVL 19

Expert Comment

by:dakyd
ID: 12046816
Oddly enough, I haven't received it.  I checked my bulk/junk folder just in case, but I don't see it there either.  Try sending it again, just in case it was a freak occurrence?
0
 

Author Comment

by:jriver12
ID: 12046962
just resent to dakyd@yahoo.com?
with 38 kb txt attachment.
0
 
LVL 19

Expert Comment

by:dakyd
ID: 12048348
I don't have Cold Fusion, so it's hard for me to sift through the <cf___> tags, but I just realized that Tcount is a string, not an integer (the value of an input is always a string).  Try changing this line:

var Tcount = (document.boothinformation.tablecount.value);

to:
var Tcount = parseInt(document.boothinformation.tablecount.value);

Not entirely sure if that'll fix your problem, but it should at least help.  Let me know if you still have problems after that.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Google adds suggestions 3 69
CSS HELP 6 90
CSS display:none AND display:block on same element 3 103
Problem to file 3 83
Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question