Contents
AbstractThis document discusses creation of a simple interactive web
user
interface for scientific and medical applications. In
particular, it describes the details behind the code for an example
interactive web page for modeling of electric gradients and action
potentials in neurons. This is done using cascading style sheets
(CSS), JavaScript, and HTML document object model (DOM). The
intended audience is people in science and medicine wanting to present
material in an interactive way over the web. IntroductionModeling of the electrical and ion concentration gradients is a fascinating topic that inspires demonstration with a dynamic user interface. The accompanying article The Nernst Equation and Action Potentials in the Nervous System does this. I also found a number of references, some of which are listed below, that provide more detailed technical treatment and even more dynamic user interfaces (references 1 through 5). However, I couldn't find a simple and informative reference that went through the calculation the way I want to see it, with the values for all the constants and terms clearly listed in a format where I could enter the exact values of the parameters that I wanted. I will describe the approach for the creation of the interactive elements of The Nernst Equation and Action Potentials in the Nervous System page. It uses dynamic HTML, which provides an interactive user interface suitable for this purpose. See the FAQ on this site for basic information on dynamic HTML. It also makes use of is made of CSS to lay out the Nernst Equation. I will use this as an example to discuss presentation of simple mathematical formulas in HTML. My choice of technology in this example is driven by several factors:
|
|
You can associate styles with text in HTML documents using the link
tag. This example shows linking our example html file action_potentials.html to the CSS
file action_potentials.css
containing the style definitions.
<link rel="stylesheet" type="text/css" href="action_potentials.css">
| EK = |
RT | ln | [K+]out |
| zF | [K+]in |
where the terms are described in the accompanying article. To see how the equation is laid out I will show it again with a light color for the hidden borders.
| EK = |
RT | ln | [K+]out |
| zF | [K+]in |
In the table definition I set the class to "equation":
<table class="equation">
This matches the following selector in the style sheet.
The border collapse attribute makes it possible to specify rules
for borders that surround all or part of a cell, row, row group,
column, and column group. With border: none I
switched the border off in general leaving it to be shown specifically
in certain table cells. This is done with the selector
I used the rowspan attribute to vertically align the elements of the equation:
<td rowspan="2">
For more on CSS see the World Wide Web Consortium (W3C)
Cascading Style Sheets home page and, in particular, the CSS 2.1
Specification6.
An alternative to doing equations in this way is to use Math Markup
Language (MathML)13.
This is an XML variant specially designed for
displaying mathematical formulas and proofs.
Equations usually use a number of symbols that are not part of a normal keyboard. Unicode is a character coding standard that has all of these symbols. In fact, Unicode has many more symbols, including Chinese, Japanese, Tibetan, and Egyptian hieroglyphics. This enables you to put even the most exotic set theory symbols on your web pages and they will be displays correctly, providing your browser has the font to display them.
UTF-8 is a standard that allows developers to put Unicode symbols in
files and over computer networks.
This includes HTML web pages. This enables web authors to put
characters from multiple languages, say
Russian, Arabic, and Sanskrit, on the same web page as complex
mathematical symbols (if they might want to). In order to take
advantage of UTF-8 and Unicode you need to set the content type at
the top of your HTML pages to UTF-8
with the line
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
Unicode characters can be written HTML documents in the form
°
(° degrees),
where 000B0 is the Unicode value in hexadecimal (base 16 ) or
° where 176 is the Unicode value in decimal.
There are also HTML entity literals that can be referred to by name.
The math symbols used in accompanying page are ·
(·) and × (×). A list of useful entities for
scientific and mathematical formulas is given in the table below.
A longer list is provided in the W3C HTML Specification11 and an
even longer list in the MathML specification13.
| Literal | Display | Description |
|---|---|---|
| × | × | Multiplication |
| · | · | Multiplication |
| ƒ | ƒ | Generic function |
| α | α |
The first character in the Greek alphabet (equivalent to Roman A) |
| β | β | The second character in the Greek alphabet (equivalent to Roman B) |
| μ | μ | The Greek character equivalent to Roman M |
| ¼ | ¼ | One quarter |
| ½ | ½ | One half |
| ′ | ′ | Prime, derivative |
| ∂ | ∂ | Partial differential |
| ∫ | ∫ | Integral |
| ∈ | ∈ | Member of (a set) |
| ∉ | ∉ | Not a member of (a set) |
| ∃ | ∃ | There exists |
| ⊂ | ⊂ | Subset |
| ⊃ | ⊃ | Superset |
| ⊄ | ⊄ | Not a subset |
| ⊆ | ⊆ | Subset or equal to |
| ⊇ | ⊇ | Superset or equal to |
| ∅ | ∅ | Empty set |
| ℝ | ℝ | Real numbers |
| ℤ | ℤ | Integers |
| ℱ | ℱ | Fourier transform |
| ⅇ | ⅇ | Exponential e |
| ∏ | ∏ | Product of a series |
| ∑ | ∑ | Sum of a series |
| √ | √ | Square root |
| ∞ | ∞ | Infinity |
| ⋅ | ⋅ | Dot operator |
| ∴ | ∴ | Therefore |
| ° | ° | Degrees (temperature, angle) |
| &211E; | ℞ | Prescription |
| Ω | Ω | Ohm |
| &212B; | Å | Angstrom |
| &210E; | ℎ | Plank's constant |