BizTalk Utilities CV ,   Jobs ,   Code library
Go to the front page to continue learning about XML or select below:


ReBlogger Contents

Previous posts in WS, web services

Page 3995 of 21350

Javascript to re-calculate summary based on user drop-down lists selections

Blogger : Michael Freidgeims Blog
All posts : All posts by Michael Freidgeims Blog
Category : WS, web services
Blogged date : 2008 Aug 17

I wanted to implement client javascript to re-calculate summary based on a few options(in drop-down lists) selected by the user .
The closest JS sample I found  was  Complex Client-Side Shopping Cart .But it wasn't exactly what I wanted.
I created an array of custom class objects. Class has InitialPrice and SelectedPrice properties as well as

this.Diff = function( ) {
return this.SelectedPrice-this.InitialPrice; 

Each DropDownList  calls onchange Event Handler, which updates SelectedPrice value and calls RecalculateTotal();

 The RecalculateTotal() basically does the following:

var totalDiff=0.0;
for(var i=0; i<g_arrOpnClasses.length;i++)
var opnClass= g_arrOpnClasses[i];

and shows recalculated summary.

Because it was my first JS code with classes, I've read a few articles to solve problems, that I meet: 
To access the HTML element the event took place on:
Event Object for IE and Firefox.
function count(evt) {
var evt = evt || event;
var myObject = || evt.srcElement;
and more complicated (but more generic) approach described at How To Create A Global Event Object For Both IE and FireFox
Considered to use JSON
To populate initial values in array I considered to use JSON, but later found that it is not nesessary. Any way below are a few links that were informative for me:

Read comments or post a reply to : Javascript to re-calculate summary based on user drop-down lists selections
Page 3995 of 21350

Newest posts

    Email TopXML