Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0ASP.NET / Javascript form field calculationsASP.NET / Javascript form field calculations
Previous
 
Next
New Post
1/23/2008 10:20 AM
 

I have searched high and low and cannot find any help out there. After developing a custom module that allows people to enter some information, there are some fields I would like to auto-calculate based on the change of another field.

Here are my fields:

UPC (textbox)
ItemQty (textbox)
ItemOrigPrice (label)
ItemTotPrice (textbox)

Upon scanning the UPC, the ItemQty defaults to 1, ItemOrigPrice displays the price, and ItemTotPrice defaults to ItemOrigPrice.

I would like it to auto calculate the ItemTotPrice upon changing the ItemQty. I have seen this done in a regular HTML form and some Javascrpit but I am having issues with having the Javascript refer to the ASP.NET tags. In the example that I saw, the Javascript refers to the HTML field name but when I try to change the to refer to the ASP.NET tag Id, it does not work. I would also like to keep it Client-side so it does not require a postback.

Example:

ItemQty :: 1 changed to 3
ItemOrigPrice :: $20.00
ItemTotPrice :: $20.00 changed to $60.00

ItemQty * ItemOrigPrice = ItemTotPrice

I hope all of this makes sense. Can anyone shed some light on this for me please? I appreciate any feedback provided to me. Thank you.

 
New Post
1/23/2008 11:39 AM
 

johnstonb,

You may find this thread from the DotNetNuke forums helpful Creating an Equation in a Table.

It references a script that uses document.getElementById to get the elements of a table and do calculations of their values. You should not have any issues with using getElementById on asp.net tags -- as they certainly have an ID. Let me know if that helps.

Here is the shortcut to the script: Summing up Columns article from 4umi.com

You will certainly have to customize it for your own purposes, but this should work -- hopefully it does not have the same flaws as the script you are currently using.

Take care,

Ian


Software Engineer
Co-Founder, dnnGallery
Stack Overflow: Ian Robinson
Twitter: @irobinson
Linked In: Ian Robinson
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0ASP.NET / Javascript form field calculationsASP.NET / Javascript form field calculations


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out