Javascript select date question

S

SamuelXiao

Hi, I am writing an application about a search booking system. When a
user input a date in an input tag yyyy-mm-dd, there is automatically
output the inputed date + 7 days, it is like:

choose your period: From: <input>________</input> To
<input>_______</
input>

When a user input 2009-05-17, the <input> after To will automatically
output 2009-05-24.

I have been doing for hours but still cannot do it. Is it must to
use
Ajax? I read the datepicker sample of Jquery UI, but it can choose
one date only. Are there any way to do it?

Any help would be appreciated.
 
T

Thomas 'PointedEars' Lahn

SamuelXiao said:
[...] When a user input a date in an input tag yyyy-mm-dd, there is
automatically output the inputed date + 7 days, it is like:

choose your period: From: <input>________</input> To
<input>_______</
input>

The content model of `input' elements is EMPTY.

HTML: <input ...>
XHTML: <input ... />

When a user input 2009-05-17, the <input> after To will automatically
output 2009-05-24.

I have been doing for hours but still cannot do it.

No wonder; it is obvious that you are lacking all the basics.
Is it must to use Ajax?

No. In fact, it is pointless to use AJAX for this particular feature.
(Do you even know what AJAX is?)
I read the datepicker sample of Jquery UI, but it can choose
one date only.

jQuery is junk.
Are there any way to do it?
Yes.

Any help would be appreciated.

If you did your homework first it would be appreciated.

<http://jibbering.com/faq/#posting>


PointedEars
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>, Sun,
17 May 2009 18:44:16 said:
SamuelXiao said:
[...] When a user input a date in an input tag yyyy-mm-dd, there is
automatically output the inputed date + 7 days, it is like:

choose your period: From: <input>________</input> To
<input>_______</
input>

The content model of `input' elements is EMPTY.

HTML: <input ...>
XHTML: <input ... />


A typical Lahn reply. To those who truly understand English, it appears
that The OP, who seems not to have a natural command of English, is
describing the screen and not the source code. It is common for angle-
brackets to be used that way, as escaped from natural language.


The OP should have read the FAQ; earlier versions would have helped.

This works, but needs refinement :-

<script>
function Fn(XX) {
var D = new Date(XX.replace(/-/g, "/"))
D.setDate(D.getDate()+7)
return D.toDateString() }
</script>

<form><input type=text name=A onChange="B.value=Fn(A.value)>
Enter yyyy-mm-dd
<br><input type=text name=B></form>



It would be easier with a DATE2 Object :-

function body : with (new DATE2(XX)) return setXDate(getXDate()+7)
or, better : return new DATE2(XX).incXDate(7).toString("Y-M-D")

The date should probably be validated Gregorian, which DATRE2 offers.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top