PDA

Click to See Complete Forum and Search --> : Really easy Q?


kanejone
Mar 7th, 2001, 08:08 AM
Hi guys
I have a form on a web page. I am creating a web page to log calls that come in. Basically what I want to do is press the button and the time and date will apprear in the text box.
Thanks a lot for your help
JK

<Form>
<input type="submit" name="Call Received" value="Call Received">
<input type="text"name="time">
</Form>

plenderj
Mar 7th, 2001, 08:31 AM
This should do the trick :


<form name="calc" action="">
<input type="text" name="time" size="20" tabindex="1">
<input type="button" value="Calculate" name="cmdDoTime" tabindex="3">
</form>
<SCRIPT LANGUAGE="VBScript">
Sub cmdDoTime_onClick()
Document.calc.time.Value = Time()
End Sub
</script>



- jamie

Mar 7th, 2001, 08:49 AM
You can also use Javascript.

<script language=javascript>
<!--

function Button_onclick() {
time.value = new Date();
}

//-->
</script>

And use this Input tag.

<INPUT id=Button type=button value=Button name=Button language=javascript onclick="return Button_onclick()">

kanejone
Mar 7th, 2001, 09:09 AM
Hi guys
Thanks a lot for the help. kayoca I can't seem to get yours working for some reason. I keep getting a time is not an object message. I've tried a few different variations. Just out of curiosity, any ideas what wrong.

Thanks a lot guys
I really appreciate the help
plenderj that works great thanks!

Mar 7th, 2001, 10:26 AM
If you just use new Date() on a variable you wil get for example Wed Mar 7 16:57:43 UTC+0100 2001

var TimeStamp = new Date();

But if you just want the time values use this code.

// Getting all the time values
var MyHour = TimeStamp.getHours();
var MyMinute = TimeStamp.getMinutes();
var MySeconds = TimeStamp.getSeconds();

// Placing the values in a time variable
var MyTime = MyHour +":"+ MyMinute +":"+ MySeconds;

kanejone
Mar 7th, 2001, 10:55 AM
Thanks a lot for the help. I really prefer using Javascript.
Cheers
JK