Results 1 to 6 of 6

Thread: Really easy Q?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    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
    Code:
    <Form>
    <input type="submit" name="Call Received" value="Call Received">
    <input type="text"name="time">
    </Form>

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    This should do the trick :
    Code:
        <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
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Guest

    Arrow Javascript

    You can also use Javascript.
    Code:
    <script language=javascript>
    <!--
    
    function Button_onclick() {
      time.value = new Date();
    }
    
    //-->
    </script>
    And use this Input tag.
    Code:
    <INPUT id=Button type=button value=Button name=Button language=javascript onclick="return Button_onclick()">

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    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!

  5. #5
    Guest
    If you just use new Date() on a variable you wil get for example Wed Mar 7 16:57:43 UTC+0100 2001
    Code:
    var TimeStamp = new Date();
    But if you just want the time values use this code.
    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;

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Location
    Ireland
    Posts
    224
    Thanks a lot for the help. I really prefer using Javascript.
    Cheers
    JK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width