
A DOM Application That Maintains the State
As Listing 7.4 illustrates, this is very easy to do with special functions.
Listing 7.4 is another version of conversion.js that prints the name of the
product next to the converted price. The script does not only look for prices,
but also for the combination of a price and a name. Figure 7.8 shows the
result in a browser.
Listing 7.4: Walking Down the Tree While Retaining State Information
function convert(form,xmldocument)
{
var fname = form.fname.value,
output = form.output,
rate = form.rate.value;
output.value = “”;
var document = parse(fname,xmldocument),
topLevel = document.documentElement;
walkNode(topLevel,output,rate) ...