Page 1 of 1

Help with JavaScript please

PostPosted: Sat Sep 13, 2008 11:59 am
by Dezo
Hey all
I got a small question:

I need to build a HTML page that has a form with one submit button. When I click on the button, I need to stop the page from submitting and then add (under the button) t a paragraph with the current time and date.

I pretty much everything working here EXCEPT it does not show the time in numbers... it shows the time in words.

Heres the code

Code: Select all
   function v(){
   var today = new Date()
   var myDate = today.getHours()
   var myTime = today.getMinutes()
   var mySeconds = today.getSeconds()
      var myParagraph = document.createElement("p")
   var txt = document.createTextNode('today');
      return false;   


Code: Select all
<form name="myform" id="myform" action="javascript3.html" method="post" onsubmit="return v()">
   <div class="formBox">
      <label for="sample">User Info</label>
      <input type="text" name="sample" id="sample" value="" />
   <div class="formBox" id="bob">
      <input type="submit" name="btnSubmit" id="btnSubmit" value="Click Me" />

Any help would mean a lot to me. Been trying (I really have) from 9AM to 1pm -


Re: Help with JavaScript please

PostPosted: Sun Sep 14, 2008 5:52 am
by Jimmy_xor
Replace the line
var txt = document.createTextNode('today');
with the line
var txt = document.createTextNode(today);

Please be more specific about the time and date format if this isn't enough..