Introduction to JavaScript

Type Conversion

Click this button to see the value in the sDate variable, calculated from a mixture of two numeric and one string variables:


This is the script we used. First we placed this in the HEAD:

<SCRIPT LANGUAGE="JAVASCRIPT">

var sMonth = "September";
var nYear = 2000;
var nDay = 27;

var sDate = sMonth + " " + nDay + ", " + nYear;

</SCRIPT>

Then we created this button:

<FORM>
     <INPUT TYPE="button" VALUE="sDate" onClick="alert(sDate)">
</FORM>