PDA

View Full Version : using onClick event with a button and textbox...



chut_dien
Nov 23rd, 2005, 06:14 AM
hi all...

let me describe my prob, hope you can understand it... :o

let say, i have a form, with some textboxes, buttons and others....

and there's this one particular textbox, with a button beside it.
when i click on the button, i want the current server time to appear in the textbox, without affecting other textboxes [or any other form attributes within that form].
i think i need to use the onClick event, but i dunno how.

can anybody help me on this? thanx in advance ;)

Vladdy
Nov 23rd, 2005, 06:18 AM
i want the current server time to appear in the textbox,
May I ask for a one good reason why?

chut_dien
Nov 23rd, 2005, 06:21 AM
errr actually my supervisor ask me on this, he needs my help.
it's for his project to build a website for the department (for business purpose).

Pyth007
Nov 23rd, 2005, 12:46 PM
Bolded items are major areas to learn...

<html>
<head>
<script>
function myFunction()
{
var dateTime=new Date();
document.getElementById('myText').value=dateTime.toString();
}
</script>
</head>
<body>
<input type='text' id='myText' value='' size='60'>
<input type='button' onClick='myFunction()' value='Click for Time'>
</body>
</html>
Although read up on Date object to get what you want...

chut_dien
Nov 25th, 2005, 01:46 AM
hye pyth..

thanx for ur help. i'll try the codes u gave. ;)
n thanx for the advice too :)