Javascript help, calculation whoes when calculating from a calculation....

I am having a strange issue with Javascript and I cannot see what the
issue us? Essentially I need to be able to calculate two values, one
is addition and the second is multiplication. I am getting some
strange numbers. My code is at the bottom under the ------, here are
the details.

crmForm.all.estimatedvalue.DataValue = 10
crmForm.all.new_cfp_estrev_nextyr.DataValue = 10
crmForm.all.new_cfp_estrev_yrtwoplus.DataValue = 10

This should make totalestrev = 30,
Then its getting weird, I am taking the following formula (10/100)*30
= 270? Here 10 is the value selected from the drop down value, I
divide that by 100 to make it a perecent and then I mulitply it by 30
which is the total from above. Why am I getting 270? In

My picklist values are (10,20,30,40,50,60,70,80,90,100)



I appreciate any help, my code is below.the comments are not a part of
the original code.

------------------------------------------------------------------------------------------
var estrev1 = crmForm.all.estimatedvalue.DataValue;
var estrevny1 = crmForm.all.new_cfp_estrev_nextyr.DataValue;
var estrevtwo1 = crmForm.all.new_cfp_estrev_yrtwoplus.DataValue;

var totalestrev = estrev1 + estrevny1 + estrevtwo1; //tiotal up all of
the values

crmForm.all.new_totalestimatedrevenue.DataValue = totalestrev; //set
variable = total
crmForm.all.new_totalestimatedrevenue.DataValue.ForceSubmit = true; //
commit to database


var totalest1= crmForm.all.new_totalestimatedrevenue.DataValue; / set
total = to new variable
var opprate1 = crmForm.all.opportunityratingcode.DataValue; //dropdown
list of whole numbers

var totalfactrev = totalest1 * (opprate1/100); //mutiply total by
dropdown divide to get percent

crmForm.all.new_totalfactoredrevenue.DataValue = totalfactrev; //set
new revenue value

0
bradlaw (133)
3/18/2008 2:19:33 PM
crm 35858 articles. 1 followers. Follow

3 Replies
1324 Views

Similar Articles

[PageSpeed] 45

I think you are having issues because you are using DataValue for your 
calculations.  According to the SDK help file, the DataValue property of a 
picklist field is the same as the selectedIndex property of a standard 
picklist.  If you used the SelectedText property you should get better 
results.

Use the alert function to see what the variable contains:
alert(crmForm.all.estimatedvalue.DataValue);

-- 
Richard Riddle
CRM Developer
Autonomix


"BLAW" wrote:

> I am having a strange issue with Javascript and I cannot see what the
> issue us? Essentially I need to be able to calculate two values, one
> is addition and the second is multiplication. I am getting some
> strange numbers. My code is at the bottom under the ------, here are
> the details.
> 
> crmForm.all.estimatedvalue.DataValue = 10
> crmForm.all.new_cfp_estrev_nextyr.DataValue = 10
> crmForm.all.new_cfp_estrev_yrtwoplus.DataValue = 10
> 
> This should make totalestrev = 30,
> Then its getting weird, I am taking the following formula (10/100)*30
> = 270? Here 10 is the value selected from the drop down value, I
> divide that by 100 to make it a perecent and then I mulitply it by 30
> which is the total from above. Why am I getting 270? In
> 
> My picklist values are (10,20,30,40,50,60,70,80,90,100)
> 
> 
> 
> I appreciate any help, my code is below.the comments are not a part of
> the original code.
> 
> ------------------------------------------------------------------------------------------
> var estrev1 = crmForm.all.estimatedvalue.DataValue;
> var estrevny1 = crmForm.all.new_cfp_estrev_nextyr.DataValue;
> var estrevtwo1 = crmForm.all.new_cfp_estrev_yrtwoplus.DataValue;
> 
> var totalestrev = estrev1 + estrevny1 + estrevtwo1; //tiotal up all of
> the values
> 
> crmForm.all.new_totalestimatedrevenue.DataValue = totalestrev; //set
> variable = total
> crmForm.all.new_totalestimatedrevenue.DataValue.ForceSubmit = true; //
> commit to database
> 
> 
> var totalest1= crmForm.all.new_totalestimatedrevenue.DataValue; / set
> total = to new variable
> var opprate1 = crmForm.all.opportunityratingcode.DataValue; //dropdown
> list of whole numbers
> 
> var totalfactrev = totalest1 * (opprate1/100); //mutiply total by
> dropdown divide to get percent
> 
> crmForm.all.new_totalfactoredrevenue.DataValue = totalfactrev; //set
> new revenue value
> 
> 
0
3/18/2008 3:23:04 PM
I think I got it working, now what if I want these calculations to
work on ONCHANGE rather than ONLOAD?

I used a mix of both types DataValue and SelectedText where it worked,
thanks!

--

crmForm.all.new_percntrevtobtg_c.style.display = "none"; //hides the
label
crmForm.all.new_percntrevtobtg_d.style.display = "none"; //hides the
field

var estrev1 = crmForm.all.estimatedvalue.DataValue;
var estrevny1 = crmForm.all.new_cfp_estrev_nextyr.DataValue;
var estrevtwo1 = crmForm.all.new_cfp_estrev_yrtwoplus.DataValue;

var TotalEstRev = estrev1 + estrevny1 + estrevtwo1;

crmForm.all.new_totalestimatedrevenue.DataValue = TotalEstRev;

crmForm.all.new_totalestimatedrevenue.DataValue.ForceSubmit = true;

var totalest1= TotalEstRev;
var opprate1 = (crmForm.all.opportunityratingcode.SelectedText/100);

var TotalFactRev = totalest1 * opprate1;

crmForm.all.new_totalfactoredrevenue.DataValue = TotalFactRev;
0
bradlaw (133)
3/18/2008 4:57:27 PM
If you would like it to run ONCHANGE then have a look at this 

http://blogs.infinite-x.net/2006/03/04/dynamics-crm-30-client-side-programming-fireonchange/

FireOnChange works great, you might not need your ONLOAD scripts after using 
the ONCHANGE


"BLAW" wrote:

> I think I got it working, now what if I want these calculations to
> work on ONCHANGE rather than ONLOAD?
> 
> I used a mix of both types DataValue and SelectedText where it worked,
> thanks!
> 
> --
> 
> crmForm.all.new_percntrevtobtg_c.style.display = "none"; //hides the
> label
> crmForm.all.new_percntrevtobtg_d.style.display = "none"; //hides the
> field
> 
> var estrev1 = crmForm.all.estimatedvalue.DataValue;
> var estrevny1 = crmForm.all.new_cfp_estrev_nextyr.DataValue;
> var estrevtwo1 = crmForm.all.new_cfp_estrev_yrtwoplus.DataValue;
> 
> var TotalEstRev = estrev1 + estrevny1 + estrevtwo1;
> 
> crmForm.all.new_totalestimatedrevenue.DataValue = TotalEstRev;
> 
> crmForm.all.new_totalestimatedrevenue.DataValue.ForceSubmit = true;
> 
> var totalest1= TotalEstRev;
> var opprate1 = (crmForm.all.opportunityratingcode.SelectedText/100);
> 
> var TotalFactRev = totalest1 * opprate1;
> 
> crmForm.all.new_totalfactoredrevenue.DataValue = TotalFactRev;
> 
0
5/20/2008 4:06:01 PM
Reply:

Similar Artilces:

Calculate Due Date?
I need a formula that will calculate a due date 10 days from the start date (a1)but if the date falls on a weekend or holiday I need the date to be the next working day. I will have a list of holidays in J2:J50. Thanks for any help.......... -- HTH Bob Phillips "Randy" <ranmcc@msn.com> wrote in message news:1121099149.930051.258040@o13g2000cwo.googlegroups.com... > I need a formula that will calculate a due date 10 days from the start > date (a1)but if the date falls on a weekend or holiday I need the date > to be the next working day. > > I will have a...

VLOOKUP Reference Help
Currently, I have a cell referencing a table on another sheet like so: =VLOOKUP(A5,'Sheet2'!$J$4:$J$1998,1,TRUE) But what I want to do is instead of referencing the sheet explicitly (i.e. Sheet2), I'd like to reference a sheet based on another cell's value. E.g.: =VLOOKUP(A5,'A2'!$J$4:$J$1998,1,TRUE) where A2 would have the value "Sheet2". Is this possible within excel? -- Thanks! Max Use the INDIRECT() function, like so: =VLOOKUP(A5,INDIRECT(A2&"!$J$4:$J$1998"),1,TRUE) -- Regards, Dave "Max" wrote: > Currently, I have...

Macro Help #5
Dear Experts I have a range in a spreadsheet set up with a macro that concatenates the row and column headings and copies the number (if it is >0) in the cell where the column heading and row heading meet to a new worksheet. A bit like looking up a street directory. Sometimes I have to change the criteria and want only numbers copied that are >10. I know how to change the macro to do this. I now have to copy numbers that are > than minus 1. Because some of the cells in the range are empty it still concatenates the empty cells the row and column headings and copies them to the workshe...

Calculated Field based on 2 Running Totals in PivotTable
I need to create a calculated field in a pivot table that would be the ratio of two running totals already in my pivot table. I would like to avoid doing the calculation in cells outside the pivot table. Here is how my data needs to look and I am unable to get the ratio calculated: Week Running Total 1 Running Total 2 Ratio 1 2 3 0.67 2 5 10 0.50 3 7 21 0.33 4 10 40 0.25 hi, ! > I need to create a calculated field i...

Trying to calculate the average cost per minute of cell phone usage
I have a spreadsheet that I�m trying to use to calculate the cost per minute of cellular calls. I have 3 plans (in rows 3, 4, and 5) that each provide a monthly cost (column a), and the number of minutes included in that cost (column b). There is also a cost per minute if you go over that allowance (cell E2). I have a field (cell C7) that I use to enter the average number of minutes used. I have a drop down list (cell C8) that allows you to select the plan you have. I have a formula that is currently written as: =SUM(((C7-C8)*E2)+A5)/C7 where: C7 = average number of minutes...

Query Help. 08-05-10
I need to query out all invalid emails. Please see the desire result below. Thank you in advance. --SQL2008 IF OBJECT_ID('Tempdb.dbo.#Temp ', 'u') IS NOT NULL DROP TABLE #Temp GO CREATE TABLE #Temp ( CounterId INT NOT NULL, EMail VARCHAR(50) NULL ) GO INSERT INTO #Temp VALUES (1, 'SmithM'), (2, 'LeeH@'), (3, 'LeeH@MHCDomain'), (4, 'NguyenJ@MHCDomain.com'); go SELECT * FROM #Temp; GO -- Desire result: CounterId EMail ----------- ----------------------- ...

Need Help with INI app
I need to store data in, update, and read data from an XML file. An INI structure worked fine: [Zone 01] a= 123 b= xyz c= etc [Zone 02] ..... I've been look around the net and cannot find a simple comprehesive example on how to convert this to VB.Net and System.Xml. Biggest problem is that the sample files do not seem to be structure such that the data can be retrived by "zone name" from the above example. First issue is how do I structure the XML file to make updates and queries? I'm working with this design currently: <Zones> <Zone Name="Zone 01&qu...

Help: Emails cannot add to the records automatically
I am using CRM 3.0, when I created an email activities and sent to external client (they are using gmail) via CRM web client, I can see a email record with GUID (CRM00030002) in the History of that contact record. When the client reply my mail, I can receive it in my Outlook Inbox with thta GUID at the subject line, however, I cannot find any email record which replied by the client appended to the activities/history of the contact record, does any has this experience and do you guus know any way to solve it? did you run the Rule Deployment wizard on the exchange server for the speci...

Conditional Formatting Help #4
If cell c6 says: ---------------------------- I would like to have D6 automatically say Approved ---------------------------- 25% or Design ---------------------------- 50% or Build ---------------------------- 75% or Shipped ---------------------------- 100% Any Ideas???? Thanks John -- John Doe ------------------------------------------------------------------------ John Doe's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=26826 View this thread: http://www.excelforum.com/show...

Help pls
Honestly, I'm only okay with MFC/C++, I'm not familiar with ATL, WTL or like that... I have downloaded 4 different wrapper classes and none of them seem to want to work in VS2005. All I want to do is read and write XML documents. Maybe append a child node here and there. That's all. Can someone popint me in the right direction here? The MSXML docs are really hard to thread through. tia B I'm using xerces-c (2.7.0) for parsing XML and I could make it work quite quickly with MFC. See http://xml.apache.org/xerces-c/download.cgi You have here also some Demos about ho...

Help update code to access 2007
I have vba code that has worked from access 97 - access 2003. It now fails in access 2007. I hope that I'm missing something simple... I'm modifying the borderwidth and bordercolor of various controls on various forms - so I created a function in a module to do the job for me. The code has a lot of other stuff in it - but here's where I'm running into problems. public function myFunction (ctl as control, intWidth as integer) ctl.borderwidth = intWidth end function The problem: In Access 2007, the control object no longer has any border properties associated with it......

Mail disappearing... help!
Hi, I hjave just re-installed Office XP and when recieving my pop3 mail I noticed messages disappearing. I have not yet re-setup my e-mail rules wizard and I looked in my deleted items folder and there was nothing there... so where is this mail disappearing to? Is there an outomatic junk mail filter of some sort? Where would it put the deleted messages? Thanks, Rich Does you have a view applied to your Inbox, such as "Unread Messages" or perhaps a filter? -- Aloha, -Ben- Ben M. Schorr, OneNote-MVP http://home.hawaii.rr.com/schorr **I apologize but I am unable to res...

Why did excel stopped showing me Macro Commands Help Window ?
I must have done something wrong. While I was in the VBA Editor working on a macro, Excel2000 used to show me suitable commands as I type in...Now suddenly it stopped. I'd appreciate if someone help me correct this. TIA Martyn When you are in the VBA editor do tools>options there you can set things like that -- Regards, Peo Sjoblom "Martyn" <ayes@post.com> wrote in message news:OHDJNvz8DHA.1636@TK2MSFTNGP12.phx.gbl... > I must have done something wrong. While I was in the VBA Editor working on a > macro, Excel2000 used to show me suitable commands as I typ...

How I calculating working days
Hi I need calculating how many working days (Mo - Fr) has past from une date to another if tony start in 01/01/2008 an finish in 22/08/2008 = 179 working days Tks >if tony start in 01/01/2008 an finish in 22/08/2008 >= 179 working days I think the correct answer is 169 Try one of these: A1 = start date B1 = end date This formula requires the Analysis ToolPak add-in be installed: =NETWORKDAYS(A1,B1) Or this one: =SUMPRODUCT(--(WEEKDAY(ROW(INDIRECT(A1&":"&B1)),2)<6)) -- Biff Microsoft Excel MVP "Centauro" <Centauro@discussions.microsoft.c...

I need help with a merge into outlook
Is there a way to import into outlook from excell that wil automatically send the email out. I know that i will have to put th email address in a column in the excel spreadsheet -- luckyg7 ----------------------------------------------------------------------- luckyg71's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1480 View this thread: http://www.excelforum.com/showthread.php?threadid=26423 Use Word's Mail Merge feature, merge to Electronic Mail, using Excel as the data source file. It'll ask which column contains the email address. :) ____________...

Please help to get the value
In a cell (a1..10) have the vllue as follows in hrs) 41.30 50.15 60.45 I want to change as 41.50 50.25 60.75 Please advice me to change the minitus portion of the time With thansk and regards Polachan Try =ROUND(A1,)+MOD(A1,1)/60*100 -- Jacob "pol" wrote: > In a cell (a1..10) have the vllue as follows in hrs) > > 41.30 > 50.15 > 60.45 > > I want to change as > > 41.50 > 50.25 > 60.75 > > Please advice me to change the minitus portion of the time > > With thansk and regard...

HELP! HTML Emails with mailto: forms in send data as an attachment!!
Hi, I am a developer and I have a windows service which uses a database to send emails. The emails are in HTML format. Some of them have <FORM action="mailto:[an email address]" enctype="text/plain"> in, so that data input into the emails form can be emailed to a specific person. This works fine with Outlook Express in that when the address in the action="" of the form gets an email, they see the forms data in plain text, (as they should). HOWEVER! If someone with Outlook (2002) fills out the form and sends it the recieved email has the form data as an a...

Row height AutoFit help
I have an Excel 2007 text table 3 columns by 1000+ rows. Many cell entries are more than one line. Some are only one line of text in all cells in the row. When global autofit for row height is applied, some of the rows with single line cell entries are adjusted as if there are two lines of text in one of the cells. I assume there must be a non printable character somewhere in the row. The entries were usually copy/pasted in. I there a way to detect these or is something else going on? Thanks, John. "Machinist60" <e_john_wilson.no.spam.@hotmail.com> wrote in mes...

A tough problem with rotas. I need Help.
Hi, This is really bugging me. i have a weekly roster of 35 staff members in the following format ................A.....................B...................C.................D ....................E 1............<<merged cells - Heading>>................................................. 2....................................11th.............12th...............13t h..............14th.........'text entries to show date 3...........Name...............Friday............Saturday.......Sunday...... .....Monday....'text entries of the day 4...........Staff 1............10:30 - 5:0...

Can a group by clause be used with a user input? Please help me.
Can a group by clause be used with an input parmeter? select count(field1),field3 from Table Group by field1, @field3 <--user inputs what field I want the user to be able to decide on specific field group by clause. The count will be on the same field everytime however, instead of making 6 functions, I thought I could make only one and have the user select from a list of different groupings. If I am not making sense let me know. I know this is a kind of weird situation. If you have done this before will you tell me what you did. I have considered a macro but I do not know if this will...

display MSDN Help of Visual Studio 97 in XP SP 2 pc
Hi, I am trying to set up Visual C++ 5.0 on my son's computer... The Visual C++ 5.0 compiler installed and seems to work fine. The MSDN Help Text display does not work, however. I understand that this relates to something in IE security. I did find a related post in this NG. My NG reader would not let me post to the thread because of the age... So, I copied and pasted the entire thread into this post.... I apologize in advance for any indiscretion that this may present. The computer I want to have MSDN Visual 97 to work on runs XP SP/2. IE version: 6.0.2900 ...

Please help with countif formula
Hello all, I have 2 columns with data: A1:A100 and B1:B100. I need some help with a formula something similar to countif. A1:A100 has names and B1:B100 has numbers. The formula that I need help with is If the cells in A1:A100 has the name with "John" and the cells in B1:B100 with values, then give me the number (count) of those cells. So I try this formula: {=count(if(and(a1:a100="John", b1:b100<>""),""))} Somehow, that formula is not working. It keeps giving me the result with 1. Please help. Thanks. No need f...

Help with Chart of Accounts
We are using GP 7.50 and have two questions: If I want to add one new natural code for each of my facilities. What is the easiest way to do this??? I have 500 locations that I need to create this one code for...I am finding myself just creating one at a time because mass modify is not helpful. Does anyone have any ideas of some shortcuts??? The second question is we have two databases created in GP. One is the test version and one is our live. I want to copy the chart of accounts built in the test version to be copied to the live version. Can someone tell me how to do this so that...

Radio or Option button? Help Please
I'm having a problem, I'm copying a test from the web which has a radio/option button to use to choose the correct answer. My problem is when I paste it into my word document it has a black square around it. How can I erase the black square, but not the button? It looks ugly and will waste a ton of ink when I print this. Thanks in advance for all your help :) Can you replace it with the radio button in word? Just delete the one that comes over from the web. Ferrell "Rhonda" wrote: > I'm having a problem, I'm copying a test from the web ...

Excel opens gibberish on startup -- Please Help
Hello, I am running excel 2002 on a client machine in a domain environment. When ever I open excel, it automatically opens several workbooks full of junk text, one of which looks like an old backup listing of my IE favorites. I don't know this happens, I've tried restalling the entire office suite and then running office updates again with no change. However, if I log in as a different user on that machine, excel opens normaly with a blank spreadsheet ready to go. I'm hoping at least somebody has experienced this before. Any help is much appreicated. thanks. First plac...