Using the const Keyword : Hyper Link Event « Event « JavaScript DHTML






Using the const Keyword

<HTML>
<HEAD>
<TITLE>const(ant)</TITLE>
<SCRIPT LANGUAGE="JavaScript">
const FREEZING_F = 32
var cities = ["A", "B", "C", "B", "D"];
var tempsF = [33, 12, 20, 40, 75];
function showData() {
    var tableData = "";
    for (var i = 0; i < cities.length; i++) {
        tableData += "<TR><TD>" + cities[i] + "</TD><TD "
        tableData += (tempsF[i] < FREEZING_F) ? "CLASS='cold'" : ""
        tableData += ">" + tempsF[i] + "</TR>"
    }
    document.getElementById("display").innerHTML = tableData
}
</SCRIPT>
</HEAD>
<BODY onLoad="showData()">
<H1>The const keyword</H1>
<HR>
<TABLE ID="temps">
<TR><TH>City<TH>Temperature</TR>
<TBODY ID="display">
</TBODY>
</TABLE>
</BODY>
</HTML>


           
       








Related examples in the same category

1.Using onMouseOver and onMouseOut Event Handlers
2.Handling onClick or Links
3.Handling onMouseOut or Links
4.Using Functions as Event Handlers
5.Using the Event Object with Navigator and Internet Explorer
6.Using onClick and onDblClick Event Handlers