Geeks With Blogs

News My Blog has been MOVED to

Michael Freidgeim's OLD Blog My Blog has been MOVED to
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:
Posted on Saturday, August 16, 2008 1:28 PM CSS/DHTML/JavaScript | Back to top

Comments on this post: Javascript to re-calculate summary based on user drop-down lists selections

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Michael Freidgeim | Powered by: