[jQuery] Cascading data into text input boxes

[jQuery] Cascading data into text input boxes

<html>
<body>
Hi folks,
I have a set of n paired text input boxes (date on; date off).  Each
is attached to Kelvin Luck's date picker plugin.
In most instances, the "date off" will be 7 days after the
"date on", and the next "date on" will be 1 day after
the preceding "date off".
So, to help the user (so that they don't have to select dates for all the
pairs of inputs), I want to:
1. for a given pair, populate the "date off" text input with a
date that is 7 days later than the one selected in the "date
on" box
2. for the following pair, populate the "date on" input with a
date that is 1 day later than that of the "date off" box (in
step #1)
3. repeat step #1 and cascade this down through the rest of the
pairs.
So far I can do step #1.  I can't do step #2 as I don't know how to
link the changed value of dateoff0 to the function being called in the
second line of the code below (i.e. what goes in xx)
<tt>$('#dateon0').change(function() {if
(this.value.length>0)$('#dateoff0').attr("value",addTheDate(this.value,7));});
$('#dateoff0').xx(function() {if
(this.value.length>0)$('#dateon1').attr("value",addTheDate(this.value,1));});
</tt>And, of course, I can't do step 3 because I'm hard coding the dateon
/ dateoff ids - there must be a way to do a loop but I can't work that
out either.
For completeness, my date-adding function is below.
I'd really appreciate some help in filling the blanks in my
capability.
Thanks,
Bruce
<tt>function addTheDate(ej,df){
    var ar=new Array();
    ar=ej.split('/'); 
    var myDate = new Date;
    myDate.setDate(ar[0]);
    myDate.setMonth(ar[1]);
    myDate.setFullYear(ar[2]);
    myDate.setDate(myDate.getDate()+df);
    var d = myDate.getDate();
    var m = myDate.getMonth();
    var y = myDate.getFullYear();
    var dmy = d + "/" + m + "/" +
y;
    return dmy; 
}
</tt>I'm at a loss on the xxx bit - how can I take the date that is
entered into #dateon, add 7 days to it, and insert it into
#dateoff?</body>
</html>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/