Wednesday, October 07, 2009

JavaScript Note: Towards Building Client-Only App

I am working on a project now where I hope to utilize JavaScript to perform some math calculation in place. Since the project will involve rather complex computation I want to avoid a round-trip to/from a server each time a user changes a value in a table cell. It would be nice the results are computed right in the browser.

I am actually new to JavaScript and up to this point I did pretty much everything on the server side, mainly using ASP.NET That's great but now AJAX and real-time (looking) page updates are quite a norm. So I am going to jot down some of the stuff that I need to pick up on this page so that I can refer them back.

Example of How JavaScript Form Can Compute and Display Standard Deviations

My first stop was to figure out how to use JavaScript to compute a standard deviation on a form page. This site contains the equation and a very straight-forward form that does that computation. My app will have significantly more complex equations but basically the idea is the same.

http://www.cs.miami.edu/~burt/learning/Math119/js-ComputeStdDev.html

After looking at this page, I have found out one drawback. All the results are displayed in the text input fields. That's OK but on an industrial-strength type app, you don't want confuse users what's input and what the output, so I need to directly output the result into some text in the page. So how would I do that....?

How To Dynamically Generate Contents or Alter The Page Content To Display Results

This is done through W3C DOM Level 1 Core built into a browser (for example Mozilla). This is described at this page with a lot of examples:

https://developer.mozilla.org/en/Using_the_W3C_DOM_Level_1_Core

OK, so I Now Know How To Dynamically Alter The Page, How Can I "Push" Parameters to Functions or some Raw Data

This is where JavaScript should be able to access a remote Data via Web Service or XML... That'e next on my list of things to research.



No comments: