Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Time into a form text field

Status
Not open for further replies.

PittLimey

Technical User
Mar 2, 2006
2
US
Hi, newbie to Javascript here... I am trying to insert the "time" at the moment the button is clicked into an existing form field. I thought it would be simple but I am just not getting it. I have tried numerous ways but none are working..

Here is where I am at the moment:
Code:
<script type="text/javascript">
function startTime()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
// add a zero in front of numbers<10
m=checkTime(m)
s=checkTime(s)
document.getElementById('Time').innerHTML=h+":"+m+":"+s
}

function checkTime(i)
{
if (i<10) 
  {i="0" + i}
  return i
}
</script>
<br>

<table border=1 bordercolor=navy cellpadding=0 cellspacing=0>

	<tr>

		<td>

			<div class=TableTitle><%%DETAIL_VIEW_TITLE%%></div>

			</td>

		</tr>

	<tr>

		<td>

			<table>

				<tr>

					<td colspan=2></td>

					<td rowspan=6 valign=top>

						<div><%%INSERT_BUTTON%%></div>

						<br>

						<div><%%UPDATE_BUTTON%%></div>

						<div><%%DELETE_BUTTON%%></div>

						<div><%%DESELECT_BUTTON%%></div>

						</td>

					</tr>

								<tr>

					<td class=TableHeader valign=top>

						<div class=TableHeader style="text-align:right;"><input type="button" value="Start Time" onClick="startTime()"></div>

						</td>

					<td class=TableBody width=300><div id=Time input size=10 type=text class=TextBox name=Type_I_StartTime value="<%%VALUE(Type_I_StartTime)%%>">&nbsp;&nbsp;</div></td>

					</tr>

				</table>

			</td>

		</tr>

	</table>

Any help would be greatly appreciated... Thanks

Dave
 
wow. first things first - run your html through a validator. that means, run this page in your browser, then click over to validator.w3.org.

your div/id situation is unique and incorrect...

then, come back and we'll be glad to help.



*cLFlaVA
----------------------------
[tt]( <P> <B>)13 * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top