Date doesnt Display

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • puT3
    New Member
    • Jul 2008
    • 145

    Date doesnt Display

    I want to display date in a textbox but it didnt show. I think my code maybe wrong but im not sure.

    Code:
    <script type="text/javascript">
    
    function tDate()
    {
    	var today = new Date();
    	
    	var tMonth = new Array();
    	tMonth[0] = "Januari";
    	tMonth[1] = "Febuari";
    	tMonth[2] = "Mac";
    	tMonth[3] = "April";
    	tMonth[4] = "Mei";
    	tMonth[5] = "Jun";
    	tMonth[6] = "Julai";
    	tMonth[7] = "Ogos";
    	tMonth[8] = "September";
    	tMonth[9] = "Oktober";
    	tMonth[10] = "November";
    	tMonth[11] = "Disember";
    	
    	var h = today.getHours();
    	var m = today.getMinutes();
    	
    	var time = "am";
    	if(h>11) { time = "pm" }
    	if(h>12) { h = h - 12; }
    	if(h==0) { h = 12 }
    	
    	document.cadangan2.dDate.value = today.getDay() + " " + tMonth[today.getMonth()] + " " +today.getFullYear() + " " + h + ":" + m + " " + time; 
    }
    </script>
    
    Date:<input type="text" name="ddate" value="tDate()"/>
    In the textbox it shows like the picture i atach.
    Attached Files
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Code:
    Date:<input type="text" name="ddate" value="<%=tDate()%>"/>
    I think we've all done this :)

    Jared

    Comment

    Working...