JavaScript Forum JS Made Easy: Free JavaScripts Tutorials Example Code
About This Product
FontsMadeEasy.com
 
The Business Internet
Find it on This page:
 
| Over 5000 Free Fonts | Tutorials | Javascript Forum | Other Javascript Resources | Cheat Sheet

     
Jsmadeeasy Forums Home   Search   Login   Register   Member List  
JS Made Easy  > JavaScript programming  > Format data  
 
Display using:  
Previous Thread :: Next Thread 
 Author Thread: Format data
servero is not online. Last active: 7/28/2004 3:52:08 PM servero
Joined: 28 Jul 2004
Total Posts: 1
 
Format data
Posted: 10 Jun 2002 02:10 AM
Hi all!!just have a little problem...i should devide a variable I did...exaclty it is a Date...and i should replace it in 3 inputbox...as dd,mm,yyyy...how could i do??thanks so much!<img src=icon_smile_big.gif border=0 align=middle>

qsaaiman is not online. Last active: 5/30/2006 4:23:08 AM qsaaiman
Top 25 Poster
Joined: 28 Jul 2004
Total Posts: 21
 
Re:
Posted: 13 Jun 2002 03:56 AM
Hi.

If you are doing the Variable in ASP then you can just do this:

Date_Var = "13/06/2002"

&lt;input type="text" name="Day" value="&lt;%= day(cdate(Date_Var)) %&gt;"&gt;
&lt;input type="text" name="Month" value="&lt;%= month(cdate(Date_Var)) %&gt;"&gt;
&lt;input type="text" name="Year" value="&lt;%= year(cdate(Date_Var)) %&gt;"&gt;

However if you are doing it in Javascript it gets a little more tricky:

&lt;script language="JavaScript"&gt;
var nDate = new Date()
var month_fix = nDate.getMonth() + 1

function split_date() // remove the function to make this insert into the form automatically.
{
date_form.day.value = nDate.getDate()
date_form.month.value = month_fix
date_form.year.value = nDate.getFullYear()
}
&lt;/script&gt;

&lt;form name="date_form"&gt;
&lt;input type="Text" name="day" value=""&gt;
&lt;input type="Text" name="month" value=""&gt;
&lt;input type="Text" name="year" value=""&gt;
&lt;input type="Button" onclick="split_date()" value="Press"&gt;
&lt;/form&gt;

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi all!!just have a little problem...i should devide a variable I did...exaclty it is a Date...and i should replace it in 3 inputbox...as dd,mm,yyyy...how could i do??thanks so much!<img src=icon_smile_big.gif border=0 align=middle>
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Quintin Saaiman
Department of Labour
IT Systems

Quintin Saaiman
Previous Thread :: Next Thread 
Page 1 of 1
 
Jsmadeeasy.com  > JS Made Easy  > JavaScript programming  > Format data