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



Home Answers Viewqa JavaScriptQuestions date in textbox on page load

Have Programming Question? Ask it here!
 
 
 


harsh joshi
date in textbox on page load
2 Answer(s)      a year and 10 months 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
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
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
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
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
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
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
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
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
javascript window.addeventlistener load
javascript window.addeventlistener load  How to load window.addeventlistener in JavaScript?   window.addEventListener('load', function() { var b = document.getElementById('box'), xbox = b.offsetWidth / 2
date
date   how to insert date in database? i need coding
load and upload. - JSP-Servlet
load and upload.  dear sir, plz give me the sol for my problem.i m waiting for u r reply. why u not replying ..   Hi Friend, We haven't remember your problem. So please send it again. Thanks
Dynamically adding textbox and labels
Dynamically adding textbox and labels  Sir, In my application I want to insert texbox and labels dynamically and want to insert database field value in that generated label. Plz help me, Thanks in advance
display data from database in textbox when id entered in textbox
display data from database in textbox when id entered in textbox  i wanted to enter data in textbox .depending on entered data in textbox data from database should be displayed dynamically in textbox
load and upload. - MobileApplications
load and upload.  Dear sir/mam, i want code for java based application, that can take .3GP video file and upload it to youtube using youtube's APIs. The video file would be located on a weblink (a direct http link to a video
retaining textbox values
retaining textbox values  i have a calculator program, when i press a button the value displays but disappears when i press another button so how can i keep values to display when i press multiple buttons
listbox and textbox validations
listbox and textbox validations  hi, any one please tell me how to set validations for listbox and textboxes using bean classes? thank you   Please visit the following link: http://www.roseindia.net/jsp/user
date
date  i want difference between the date entered in a jtextfield and the system date in java
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
Hibernate Session Load
This section contain description of Hibernate session load
Load function ***PLEASE HELP
Load function ***PLEASE HELP   Hi I am writing a program that tracks... a load function that prompts the user for the file name to be loaded and then it loads the stats. Here are the exact instructions. LOAD: Prompts the user
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
binding data with textbox on dropdown click
binding data with textbox on dropdown click  Hello friends,Divyesh here. i have jsp page and i would like to bind data with text box on dropdown click. in dropdown employee id are load.and when we select perticular id than how
Sql Server 2008 with textbox
Sql Server 2008 with textbox  **Hi, I tried to insert into DB using textbox in a form using vb by visual studio 2010 but its always catch an error [Cannot open database "4" requested by the login. The login failed. Login failed
javascript for textbox - JSP-Servlet
javascript for textbox  Dear sir , How to write a javascript for a textbox ?.I am doing a delet operation.When i clik on a particular record that record should be deleted before deleting it an alert message is shown
Advertisements
 

 

 

DMCA.com