Computer Science Canada

JavaScript text box question..

Author:  who cares? [ Thu Sep 16, 2004 4:50 pm ]
Post subject:  JavaScript text box question..

ok, i've done 2 years of Turing so far, but now i started JavaScript at school...

the teacher made us write a program that tells time and refreshes every second....

anyways, can you please tell me of a way to display that "clock" (just text, nothing else) in a text box?

thanks a lot!

Author:  Dan [ Thu Sep 16, 2004 4:53 pm ]
Post subject: 

This is not a fourm for java scripted, this is a forum for the progaming langue java. java scripted != java.

I am moving this to html/webpage section.....

Author:  wtd [ Mon Sep 20, 2004 3:54 pm ]
Post subject: 

Create a textbox with HTML and gove it a unique ID. Then simply access that object and set its value property. Something like the following should work, though I haven't tested it.

code:
<html>
<head>
   <script type="text/javascript" language="javascript">
      function displayTest() {
         document.getElementById("test-field").value = "Hello world!";
      }
   </script>
</head>
<body onload="displayTest();">
   <form>
      <input type="text" id="test-field"/>
   </form>
</body>
</html>


: