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
1072 Views

Similar Articles

[PageSpeed] 5

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 the average using the Lookup function or similar
Hi! I'm using the lookup function to find a specific share price for a certain date and that works great. However, I would now like to be able to calculate the average for a certain period, for example a quarter. This would be approx 65 observations starting at a defined date and ending at another defined date - everything in columns. My question is now wheter I can qombine the lookup and average function in order to achieve this? ..or any other way to do this? I have tried with =AVERAGE((LOOKUP(C4,'share price'!$B$3:$B$1007,'share price'!$C$3:$C$1007)),(LOOKUP(E4,...

help on applying group policy to PC's
Hi, At our company we have 2 windows 2000 servers running. I am in Active directory. I have created an OU (called software deployment) in which I have placed a PC. (I will be adding more PC's to this OU but not just yet). Can someone explain the steps to take to deploy an application centrally to this PC so that when a user reboots his PC, the software is installed... Thanks Vijay Wrong newsgroup.... better posted in microsoft.public.win2000.group_policy or microsoft.public.windows.grouppolicy. -- Bharat Suneja MCSE, MCT www.zenprise.com blog: www.suneja.com/blog -------------...

Help me
Is there a way to make a single gridline bolder than the rest? No but you could add a dummy series as a straight line and format it to fit your need See http://www.andypope.info/charts/averageline.htm best wishes -- Bernard V Liengme www.stfx.ca/people/bliengme remove caps from email "ejennings" <ejennings@discussions.microsoft.com> wrote in message news:E4B1B4C5-907B-49BA-B92D-F7CAFDB3FEB1@microsoft.com... > Is there a way to make a single gridline bolder than the rest? ...

Undeliverable Messages / Help Needed Exchange 2003
Hello Guys, We have a WINDOWS 2003 Server standard running exhcnage 2003 in our remote office. Our main office has their emails setup with earhlink which are forwarded to their verizon accounts. last night the exchange server was rebuild from scratch and now everybody in our remote office gets an error when they are trying to email anyone from the main office. Please take a look at the diagram for better understanding of our problem. http://tsweb.ma.cx/mainpath.jpg so to summurize what's going on when user1 sends an email to user2, user3 or user4 evertthing works fine, but when any ...

need some help
Hi, This is probably a stupid question, I have been trying to understand but I would need some to explain it. I have an SDI app (a treeview to the left and a CFrameWnd to the right, I switch between a couple for CFormView) I don't have a CDocument class in my project, so I get these kind of errors "Warning: Creating a pane with no CDocument." Now my problem is I don't know why I need a CDocument. In the msdn help I can read "CDocument supports standard operations such as creating a document, loading it, and saving it. The framework manipulates documents using the interfa...

HELP! Emails
Having problems with windows xp, system is crashing. I trying to backup all of my files on to a CD. I can't locate the files that contain my inbox. Outlook express not working. Can anyone tell me where I can find these files in my system. Thank you Hi, Bobbie: This is a group to support Outlook from the Office group of programs. Outlook Express is a part of Internet Explorer and is a quite different program, despite its similar name.. You will probably get a faster and more expert answer if you post this to an Outlook Express news group. Try posting in one of these newsgroups: mic...

opening outlook with mailto from javascript (in html mode)
I like the abilith to use href=mailto:xxx@xxx.com?body=This is in the body The problem is that I can not get the default e-mail tool (Outlook) to open up in html format. It seems to only support plain text. If I do not add the body part of the href, then it opens in the default format which for me is html. Any ideas? Thanks in advance. Jim As I understand it, this is a limitation of the way Windows passes the mailto: command to the default email program. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Dev...

Who could help me about database?
Hello all: Look: class CRs:public CRecordset//throught ODBC { }; CRs Rs; Rs.Open(); ..... Rs.Requery(); just now I want to know how many numbers of records, and I want to know what number of current record?Tnank you very much. Why not just use GetRecordCount() and GetStatus()? Tom "Lee Tow" <fbjlt@pub3.fz.fj.cn> wrote in message news:usvPcv9VGHA.5288@TK2MSFTNGP14.phx.gbl... > Hello all: > Look: > class CRs:public CRecordset//throught ODBC > { > }; > CRs Rs; > Rs.Open(); > .... > Rs.Requery(); > just now I want to know how many numbers ...

HELP!!!!
Working with a friends money 99 program. Go out to update internet information and i get 2- The Symbol US:JASSX is invalid and The symbol US:jmed is invalid....any ideas?? Also, Product information: money was unable to complete the operation. The internet banking, or brokerage server you were trying to contact encountered an error. please try your call again later. (SMC) My e-mail is Altec14942@aol.com if anyone can help on these to problems....THANKS 1. well.. all that suggests that you have a firewall or a router or your connection is not setup so money can read it.. it you have a...

Help with shariing excel file !
Hi, I have strange problem since a few weeks with an excel file I share. This file is stored on aW2003 SBS. It can only be modified by one person (it has a "modify" password is set). The file is *always* opened from the same station, by the same user ! I set this thru : "Save as", then "Tools", "General option". Now, sometimes, when this famous user opens the file, it gets an error, which tells him that... the file is already opened by ... him ! Of course, it can't modify it since the file is exclusive ! I tried to reboot the station, nothing ! The ...

re help
hi i have just installed vista on my comp and all is working well im using windows mail and just wanted some more stationery so i went to down load Microsoft's own but can i find it when it installs it it does not put it into the windows mail stationery file ? why not any help ...

i seem to be having memory issues, will deplying a release build instead of a debug build help with memory usage of my .net process?
i seem to be having memory issues, will deplying a release build instead of a debug build help with memory usage of my .net process? ...

VBA forms
Hello, I'm using the following in a macro but it doesn't work: Range("A2:A65536").Select If Cells.Select = "0" Then Selection.ClearContents What should I change??? Hi what are you trying to achieve ? -- Regards Frank Kabel Frankfurt, Germany "One-Leg" <OneLeg@discussions.microsoft.com> schrieb im Newsbeitrag news:09BDF4EF-22F3-4223-B2FD-B45D8EB37D7F@microsoft.com... > Hello, > > I'm using the following in a macro but it doesn't work: > > Range("A2:A65536").Select > If Cells.Select = "0&quo...

Event Macro help
I would like to record and display the date in a column when a particular event happens. For example, I'd like to display the date that each row in Column A displays "Complete." If the task in A1 is completed today, I'd like B1 to display "3/22/2010" and for it to stay that way unless changed or deleted. Thanks! 'Note that for this to work, column A must be manually changed, 'not a formula creating an output. Private Sub Worksheet_Change(ByVal Target As Range) 'Is it a cell we care about? If Intersect(Target, Range("A:A"...

XMLSerializer for javascript
Hello, Can XMLSerializer be called from javascript ? How can I use XMLSerializer on the client side, and on the server side ? I need an example, please. Thanks :) Mr. x wrote: > Can XMLSerializer be called from javascript ? Not in javascript, but in JScript.NET. > How can I use XMLSerializer on the client side, and on the server side ? XmlSerializer (if you're talking about System.Xml.Serialization.XmlSerializer class of .NET) requires .NET environment. On server side it's usually ASP.NET, on client side - Windows forms or Web Forms. -- Oleg Tkachenko http://www.tkachen...

Formula Help #35
I need help formatting several fromulas. The first is: I have a column of % (test grades). I would like to have Excel calculate the # of grades that fall within certain perameters, such as 90-100, ,80-89 etc. How can I write a formula to calculate this? I've tried variations of Count with conditions, but I obviously haven't figured out the right thing to do. Second: When computing a column to obtain the AVERAGE, I'd like EXCEL to ignore the zeros (0), as those students would have been absent. It is Wednesday night, ,just after 9:00. If you replay aoutside of an hour ...

OH, I need help fast.(Excel-Adobe)
Can an Adobe file be converted to an excel file? I have a 7 page report in Adobe and I need only part of it & I need to be able to make changes. I REALLY don't want to type this whole thing again, if it would only let me cut and paste, NOOOOOOO. Please help, I have to do it before I can leave work today. Thanks DKR, If you open the .pdf file in Adobe Reader rather than Adobe Acrobat, you should be able to select all the text you want, and paste into Excel. -Michael H "DKR" wrote: > Can an Adobe file be converted to an excel file? I have a 7 page report in &...

Calculating totals
I have two columns on a worksheet: "Project Codes" and "Totals." I would like to have columns on another worksheet that will automatically total up the different project numbers "A,B,C,etc." How do I do that? Thanks in advance for your help, Technically Handicapped Enter a *unique* list of your "Project Codes", starting in A2 of Sheet2. In B2, enter this formula: =SUMIF(Sheet1!A:A,A2,Sheet1!B:B) And copy down as needed. -- HTH, RD ===================================================== Please keep all correspondence within the G...

Help!
One of our user quit so I disable his account, after 1 week a replacement came, I enable the account and reset the password for the new user. The problem is I can not access the mailbox anymore. Is there a setting in Exchange 2k3 that I need to reset? Please Advice Thanks in advance Hi Joey, There could be a couple reasons for this. In the user account check to make sure there are Email addresses ie. the Recipient update service is functioning. Also in the ESM drill down to the mailboxes in the Information store \mailbox store\mailboxes, right click on mailboxes and click 'Run ...

Replacing Character in Cell
Hi Everyone, I am trying to replace certain characters in a cell using Ctrl + F -> Replace but I think I am doing something wrong. Can anyone help? 1. I have Number(1 to 13) & Alaphabet combined code looking like thingy from A1:AM65536. Yes there are alot of them. e.g. 1D2D4C13H12C etc 2. I am just trying to replace 13 with "K", 12 with "Q" 11 with "J" and 1 with "A". 3. How do I replace those? thank you If you do "Edit & Replace" 4 times, starting with 13 first, then working down, I don't see any problem. That is, unless...

Code Help
hi guys, i have a vb question. i have the following code: ____________________________________________________ Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Then Exit Sub If Intersect(Target, Range("B6")) Is Nothing Then Exit Sub If (Target.Value) = "Rental" Then Range("F6").NumberFormat = "$#,##" Else Range("F6").NumberFormat = "0.0%" End If End Sub ------------------------------------------------------------------------------------ how do i make it so that if b6 changes, then ...

Vlookup / Objects help XL2003
Hi I have a table with some measurements in and a "freeform" drawing for each row. EG A B C Model1 Size1 "Freeform 1" Model2 Size 2 "Freeform 2" I am familiar with Vlookup but is it possible for me to say lookup the model in column A and return contents of C (ie the drawing). I'm currently getting zero returned as the drawing is just placed in the cell - is there away of attaching the drawing to the cell? Hope this makes sense Thanks Steve Hi see: http://www.mcgimpsey.com/excel/lo...

I do something wrong with SendMail macro...Please help
Hello! I would like to refer to Ron de Bruin's macro that should make i possible to mail sheet or sheets to one or more people, described o his I-net site; www.rondebruin.nl/sendmail.htm I added a sheet "mail" to my workbook and added 6 columns(needed t send out the two sheets that I would like to send) : The macro looks like this: Sub Mail_sheets() Dim MyArr As Variant Dim a As Integer Dim Arr() As String Dim N As Integer Dim strdate As String Dim wb As Workbook Dim cell As Range For a = 1 To 253 Step 3 If ThisWorkbook.Sheets("mail").Cells(2, a).Value = ""...

HELP: Outlook 2002 = doesn't chk all mailboxes consistently
I have 4 email accounts that Outlook 2k2 is supposed to check. When I send/receive it only checks the last 2 like 1 out of 10 times. Any ideas why? It simply checks the first 2 then skips the rest! Thanks. What patch level is Office XP at? How do you have the intervals set for checking mail? Try setting the interval to 10 minutes and see if that helps. Also, what types of accounts are the 4? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. After searching google.groups.com and finding no answer: VB Programmer <RobertNZana*NoSpam-Pl...

Help with Subforms
I have a form with a textbox and a subform. I want the subform to be filtered based on what the value in the textbox is. I have a table with vendors, invoices and dates. For each vendor in the textbox, I want the subform to contain the invoices and date reated to the vendor. How can I accomplish this? Thank you If the textbox is unbound, or there is not a relationship between the table/query its bound to and the table/query your subform is based on, you will need an event to trigger the updates in the subform. This can most easily be accomplished with a button's OnClick event in...