I created a function called StartTime() that populates a drop down list with Times and gives the list a name of Start_Time and property of inChange to call the function calcTime(). Thus when the user changes the value of the drop down list the onChange() function is called and it should dynamically populate the <input type="text"> field
I am puzzled why this is not working... Is it because I am referring to one function in another??
Some guidance of this issue would be great or a sample on how to make this work...
Code:
<html>
<head>
<title>
</title>
<SCRIPT language="JavaScript">
function StartTime()
{
var ampm="AM"
document.write("<SELECT>")
for (var hour=5; hour<24; hour++)
{
for (var min=0; min<=45; min=min+15)
{
if(min==0)
{
if(hour>12)
{
hour=hour-12
ampm="PM"
document.write("<option name=Start_Time onChange=calcTime() value="+hour+">"+hour+":"+min+min+" "+ampm+"</option>")
hour=hour+12
}
else if(hour==12)
{
ampm="PM"
document.write("<option name=Start_Time onChange=calcTime() value="+hour+">"+hour+":"+min+min+" "+ampm+"</option>")
}
else
{
document.write("<option name=Start_Time onChange=calcTime() value="+hour+">"+hour+":"+min+min+" "+ampm+"</option>")
}
}
else
{
if(hour>12)
{
hour=hour-12
ampm="PM"
document.write("<option name=Start_Time onChange=calcTime() value="+hour+">"+hour+":"+min+" "+ampm+"</option>")
hour=hour+12
}
else
{
document.write("<option name=Start_Time onChange=calcTime() value="+hour+">"+hour+":"+min+" "+ampm+"</option>")
}
}
}
}
document.write("</SELECT>")
}
function calcTime()
{
var d = document.timesheet;
var Start = d.Start_Time.value;
d.hoursworked.value = Start;
alert(Start)
}
</script>
</head>
<body>
<FORM NAME="timesheet">
<script lanuage="javascript">StartTime()</script>
<input type="text" name=hoursworked></script>
</form>
</body>
</html>
Newbie in search of knowledge