SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    simple time script p[roblem

    Whatrs wrong with this?

    Code:
    <script language="javscript">
    
    function button1()
    {
    
    var t = new Date();
    document.forms[0].box1.text = t.toString();
    
    }
    
    function button2()
    {
    
    var t = new Date();
    document.forms[0].box2.text = t.toString();
    
    }
    
    </script>
    
    <input type="button" onclick="button1();" value="one">
    <input type="button" onclick="button2();" value="two">
    
    <input type="textbox" name="box1">
    <input type="textbox" name="box2">
    Free Science Homework Help
    http://www.physicsforums.com

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script language="javascript">
    
    function button1()
    {
    var t = new Date();
    document.forms[0].box1.value = t.toString();
    }
    function button2()
    {
    var t = new Date();
    document.forms[0].box2.value = t.toString();
    }
    
    </script>
    
    <input type="button" onclick="button1();" value="one">
    <input type="button" onclick="button2();" value="two">
    
    <input type="text" name="box1">
    <input type="text" name="box2">
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I get an error that says an object was expected
    Free Science Homework Help
    http://www.physicsforums.com

  4. #4
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, we obviously aren't looking at all the HTML here, because you reference a form yet I see no <form> element

    That is, unless, you didn't actually include it in the first place [img]images/smilies/tongue.gif[/img]
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  5. #5
    SitePoint Wizard dethfire's Avatar
    Join Date
    Aug 2000
    Posts
    2,477
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by beetle
    Well, we obviously aren't looking at all the HTML here, because you reference a form yet I see no <form> element

    That is, unless, you didn't actually include it in the first place [img]images/smilies/tongue.gif[/img]
    ok well... I put in form tags and it still doesn't work
    Free Science Homework Help
    http://www.physicsforums.com

  6. #6
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I dunno. This works just fine for me (although I prefer to put scripting in the head)
    Code:
    <html>
    <body>
     
    <script language="javascript">
    	function button1()
    	{
    		var t = new Date();
    		document.forms[0].box1.value = t.toString();
    	}
    	function button2()
    	{
    		var t = new Date();
    		document.forms[0].box2.value = t.toString();
    	}
    </script>
     
    <form>
    	<input type="button" onclick="button1();" value="one">
    	<input type="button" onclick="button2();" value="two">
     
    	<input type="text" name="box1">
    	<input type="text" name="box2">
    </form>
     
    </body>
    </html>
    Perhaps you could be a little bit more detailed? "it still doesn't work" just doesn't cut it.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





Bookmarks

Posting Permissions

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