• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Date foramt

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everybody,

I have 2 text fields iam entering Date as input.
suppose if i click on first text field the second text filed should automatically take date as "dd-MON-YYYY" format.

Thanks in advance
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you mean fill the current date in second field, using that specific format, on click of the first field?

Or

Do you want the date in the first field to be printed in second field in that specific format?

Anyways, you can use java.text.SimpleDateFormat class.
 
Ravi Kumar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for replying.

Let me put clear.

I have 2 text feilds.In first text field if i entered date.
for Ex:if i entered '09-Apr-2007'the second text filed should automatically display date as '10-Apr-2007'(i,e date+1).

Thanks....
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you not hava a Javascript reference avaiulable so that you can inspect the API of the Date class?
 
Ravi Kumar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have written a method in javascript.
i have used below method,but it is not supporting..

var dt=new date(ref.setDate(ref.getDate)+1)

pls suggest a quick solution for my problem.
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by yadav kumar:

var dt=new date(ref.setDate(ref.getDate)+1)




what you are trying to achieve with line of code?
[ April 10, 2007: Message edited by: Saif uddin ]
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
see here some example to understand how we can play with JavaScript Date Object
 
Ravi Kumar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
get_date(obj)

var pdate=doucment.frm.getElementSByName("pdate");

if (pdate! =null)

var sdate=new date(pdate.setDate(pdate.getDate)+1);

sdate is getting as null.

please give me soultion.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"S" should be small getEelementsByName()
if you are getting a element value by using a form then no need to use this method.

follow the simple way :


and another thing is.



.setDate This method is always used in conjunction with a Date object.



hope it helps..
[ April 11, 2007: Message edited by: Saif uddin ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getDate is a method so you need to use ()

also getElementsByName is an array

Eric
 
Ravi Kumar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all thanks for replying .

Main my problem is that iam not able to get the date value

i mean when i call below statment

In javascript

get_date(obj)
{
var pdate=doucment.frm.getElementsByName("pdate");

if (pdate! =null)
{
var pdate=doucment.frm.getElementsByName("pdate");

alert('pdate'+pdate); //pdate is getting as null

var sdate=new date(pdate.setDate(pdate.getDate)+1);
}
}


iam getting as null because iam not able to get the value of pdate

In JSP
String pdate=""

//pdate=request.getParameter("pdate")


input type="text" value="" name="pdate"
javascript:show_calendar('forms[0].pdate');
ahref="javascript:get_Date(this);"

Note: pdate iam passing input as dynamic

Sorry it may contain some syntax errors please ignore it

Thanks
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yadav,

You have several people trying to help you with this. It would hep you get a meaningful response if you would post your actual javascript code and your html. There are any number of problems that could prevent you from getting a reference to your input object. If you don't post code, we're all just guessing at things that could possibly be wrong.
 
Ravi Kumar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is below code It's is the main logic.

This is from javascript.

get_date(obj)
{
var pdate=doucment.frm.getElementsByName("pdate");

if (pdate! =null)
{
var pdate=doucment.frm.getElementsByName("pdate");

alert('pdate'+pdate); //pdate is getting as null

var sdate=new date(pdate.setDate(pdate.getDate)+1);
}
}


iam getting as null because iam not able to get the value of pdate

This is from JSP

String pdate=""

"<"input style="width:70px; font-size: 10px;" value=""<"%=pdate%"<"" maxlength="11" name="pdate" type="text""<"
"<"a ="javascript:show_calendar('forms[0].pdate');" href="javascript:get_Date(this);""<"

This reason is before calling show_calendar method it is going to get_Date method as a result pdate is null.

Thanks.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
change you get_date function with this..



hope it works for you..
 
Legend has it that if you rub the right tiny ad, a genie comes out.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic