You have quite a few errors in your code.
First, your form doesn't have a name and your controls don't have ids so there is no elegant way to access them. Either give you select boxes some ids (id="some_id") or give your form a name (name="some_name").
You can then reference your controls using either document.getElementById("some_id") or document.forms["some_name"].elements["hrnum"].
Second, your javascript isn't quite correct. You should place a function call as the click handler for your button:
HTML Code:
<input type="button" value="Calc" onclick="calcTime()" />
At the end of the javascript section, replace all that follows // Output to text field... with the following function declaration:
Code:
function calcTime()
{
// Make sure you have "timeform" as the name of the form.
var time = new Time(
document.forms["timeform"].elements["hrnum"].selectedIndex,
document.forms["timeform"].elements["minnum"].selectedIndex);
time.AddHours(1);
document.forms["timeform"].elements["nextHour"].value = time.AsString();
}
Bookmarks