Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions date in textbox on page load
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


harsh joshi
date in textbox on page load
2 Answer(s)      2 years ago
Posted in : JavaScript Questions


i want to insret the current date in textbox but this code dosen't work and the value of text box will be blank

 <script type="text/javascript">

        function addDate() {

            var mydate = new Date();
            var year = mydate.getFullYear();

            var day = mydate.getDay();
            var month = mydate.getmon() + 1;
            if (month < 10) {
                month = "0" + month;
            }
            var daym = mydate.getDate()
            if (daym < 10)
             {
                 daym = "0" + daym;

            }
             today = day + month + year;
            return today;

        }
        window.onload = function()
        {

            document.theForm.text3.value = addDate();

        }


    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>

    Today date is : <input type="text" id="txtdate" />
    <INPUT id=text3 name=text3   />


  </div>
    </form>
</body>
</html>

Advertisement
View Answers

October 3, 2012 at 3:42 PM


Here is a javascript code that insert the current date into textbox on page load.

<html>
<script>
function addDate(){
date = new Date();
var month = date.getMonth()+1;
var day = date.getDate();
var year = date.getFullYear();

if (document.getElementById('date').value == ''){
document.getElementById('date').value = day + '-' + month + '-' + year;
}
}
</script>
<body onload="addDate();">
Today's Date is: <input type="text" id="date">
</body>
</html>


October 4, 2012 at 9:30 AM


thanks



Related Tutorials/Questions & Answers:
date in textbox on page load
date in textbox on page load   i want to insret the current date in textbox but this code dosen't work and the value of text box will be blank... into textbox on page load. <html> <script> function addDate(){ date = new
session on page load
session on page load  holding session on page load and reload..   <?php session_start(); if (!isset($_SESSION['arr']['counter'])) { $SESSION['arr']['counter'] = 0; } else { $SESSION['arr']['counter']++; } var_dump
Advertisements
get date picker values to a textbox
get date picker values to a textbox  I am using DatePicker to select date in a form in asp.net using c#. I need the picked data to get in to a textbox. Please help me soon
How to display current date in textbox - Date Calendar
;% } This is my problem: I want to display current date in textbox...How to display current date in textbox  Hi guys, I'm really need your... Date(); var month = currentTime.getMonth() + 1; var day
optimze page load - Java Beginners
optimze page load  Hi there My code everything works fine. But i.../calendar.gif", buttonText: "Due Date", buttonImageOnly: true...", buttonText: "Due Date", buttonImageOnly: true}); }); function onLoad
keeping log of page load - Java Beginners
keeping log of page load  Hello, I have a project and I need... on is developed by someone else. The problem with this JSP page is that sometime it loads very nicely but sometimes it doesn't load proper way and it times out. I
pre Page load display an image loading - JSP-Servlet
pre Page load display an image loading  hi, We have requirement some pages are loading very slow, while the page is processing we need...;Hi Friend, Do you want to display image before loading page? Please clarify
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE ... SystemAdmin 2 Office Bearer Am loading this Rolename into one page called... is how to get Roleid in textbox when i select Role_name from combobox in a same
how to load a table of data from oracle, to a jsp page using hashmap.
how to load a table of data from oracle, to a jsp page using hashmap.  I have a jsp page which ask for project ID,team name,member name according to this data i have to retrieve their details from the database(oracle). I have
passing textbox value from one page to another page using html n javascript
passing textbox value from one page to another page using html n... of variable at onclick event of button and also want to print it in textbox on the othe (next/prevoious)page please help me   1)page1.html: <html>
Form Should not load
Form Should not load  I have a jsp page which has textbox and dropdown box, when I submit it, the page reloads and the textbox and dropdown box also... box after submitting or the form should not load again. Thanks in adbance
Calendar window is not showing the textbox values for the Dynamic rows in html page - Java Interview Questions
Calendar window is not showing the textbox values for the Dynamic rows in html... is not showing in textbox please help to me it is very urgent for me Add...: 1.0 // Date: 12-05-2001 (mm-dd-yyyy) // Author: Denis Gritcyuk ; // Notes
Addintion in year fields of sql date in a java page
Addintion in year fields of sql date in a java page  In my database i have a field StartDate and EndDate Now entering date from my jsp..., HttpServletResponse response) throws ServletException, IOException { Date
Ajax Load
Ajaxload The ajaxload is a tool, which follow web2.0 standard. Due to slow Internet speed or delay some times data takes time to load. At this time we... the image and can use this image directly in your web page
jQuery Ajax load request
jQuery Ajax load request  Hi, How to use jQuery to send the request on server to load data in web page? Thanks   Hi, In the jQuery Load... and then load the data in web page. Thanks
Write an Applet which display current date and time on the web page??
Write an Applet which display current date and time on the web page??  Write an Applet which display current date and time on the web page??  Here is an applet code that display date and time. import java.applet.
Write an Applet which display current date and time on the web page??
Write an Applet which display current date and time on the web page??  Write an Applet which display current date and time on the web page?  Here is an applet code that display date and time. import java.applet.
J2me Map load error
J2me Map load error  Hi , i am making a POC to load google map in my mobile,now i m getting the address of location by its lattitude and longitude in web page , but thing is i wana to store in my net beans emulator , its showing
Load Icon Image Exception
Load Icon Image Exception  Load Icon Image Exception
how to load pdf on html
how to load pdf on html  how to load pdf on html
Load UIImage from URL
Load UIImage from URL  Load UIImage from URL
SQl Date
SQL Date       The SQL Date is used when you are working with dates. This include...; in the database. The query contain only the date portion, which you want
nsstring load from file
nsstring load from file  Hi, How to load file data into NSString object? Example of nsstring load from file, basically the html file data into NSSTring object. Thanks
JavaScript Show Date
JavaScript Show Date..., we are going to display the current date using JavaScript. You can see in the given example, we have created Date object which holds the current date and time
UIWebview load url
UIWebview load url  How to load website url in UIWebview? Tell me code for UIWebview load url of a website Thanks...: //Load web view data NSString *strWebsiteUlr = [NSString stringWithFormat:@"http
load more with jquery
load more with jquery  i am using jquery to loadmore "posts" from my... box its is going to display php posts and after that when i click on load more...); $('#loadmorebutton').html('Load More
Getting mysql table in textbox
Getting mysql table in textbox  how to get mysql table values into textbox in java using ajax and servlets
showing the information of database in textbox
showing the information of database in textbox  how to make a information of a database make appear to the user in the textbox
XML load problem - XML
XML load problem  I have load the xml document in javascript.getting error like ActiveXObject is undefined.Can you help me?  Hi friend... function load(){ var loadXML = new ActiveXObject
date
date   how to insert date in database? i need coding
Load on Startup - JSP-Servlet
Load on Startup  Hi, Can anybody explain the exact use of load-on-startup tag. Where exactly we have to write. Thanks, Naveen  ... of a deployment descriptor is used to load a servlet file when the server starts instead
 

 

 

DMCA.com