alwclimbs
01-05-2011, 09:35 PM
If you take a look at the attached image you will see that the person has the choice of picking a membership duration of 3 months, 6 months, or One Year.
The Membership Begin date automatically calculates today's date. I want to be able to have the Membership Ends field correctly give the membership ending date based on what Duration is chosen.
Ex. 1/05/11 + 3 Months = 4/05/11
Problem: The membership for One Year is value set for 11 because of a discount. I need to add one month to make the date correct.
I've tried alot of codes and I'm getting no where! Thank you for the help!
List Box name - "Duration"
jmrker
01-06-2011, 02:28 AM
Can you post some sample code of your problem so that we do not need to start from scratch?
Philip M
01-06-2011, 08:03 AM
This should do the trick.
<form name = "myform">
Enter Memebership Begins Date DD/MM/YYYY <input type = "text" name = "date1" id = "date1">
<select name = "duration" id = "duration" >
<option value = 0>Select membership duration</option>
<option value = 3>3 months</option>
<option value = 6>6 months</option>
<option value = 9>9 months</option>
<option value = 12>12 months</option>
</select>
<br>
Membership Ends Date <input type = "text" name = "date2" id = "date2" readonly><br><br>
<br><br>
<input type = "button" value = "Check Date and add 3 months" onclick = "checkit()">
</form>
<script type = "text/javascript">
function checkit() {
var dur = parseInt(document.myform.duration.value);
if (dur == 0) {
alert ("You must choose a membership duration");
return false;
}
var d1 = document.myform.date1.value.split("/");
var yr = d1[2];
var mm = d1[1]-1;
var dy = d1[0];
var OK1 = checkValidDate(yr,mm,dy);
if ((yr < 2010 || yr > 2030)) {OK1 = false} // year must be 2011 - 2030
if (!OK1) {
alert ("Invalid date or incorrect format! Please try again.");
document.myform.date1.value = "";
return false;
}
var secondDate = new Date(yr,mm+dur,dy)
var year = secondDate.getFullYear();
var month = secondDate.getMonth()+1;
if (month <10) {month = "0" + month}
var day = secondDate.getDate();
if (day <10) {day = "0" + day}
var futuredate = month + "/" + day + "/" + year;
document.myform.date2.value = futuredate;
}
function checkValidDate(yr,mm,dy) {
var nd = new Date();
nd.setFullYear(yr,mm,dy); // YYYY,MM(0-11),DD
var ndmm = nd.getMonth();
if (ndmm != mm) {
return false;
}
else {
return true;
}
}
</script>
"There’s a great similarity between Britain's – or any democratic nation’s – voters and domestic livestock. They both are more concerned with what is provided in the trough today than what will happen to them on the morrow."
alwclimbs
01-06-2011, 01:40 PM
The only coding that I have to reference from is the beginning date which is
event.value = util.printd("mm/dd/yyyy", new Date());
Phillip, it says that there is invalid XML code.
I hate PDFs...
jmrker
01-06-2011, 03:10 PM
The only coding that I have to reference from is the beginning date which is
event.value = util.printd("mm/dd/yyyy", new Date());
Phillip, it says that there is invalid XML code.
I hate PDFs...
So where did the image come from.
What code created that?
:confused:
alwclimbs
01-06-2011, 03:20 PM
Those boxes are simple list boxes created in Acrobat that have export values based on pricing and duration.
The membership begins code I posted and the end membership text box is the one that is blank and I can't figure out anything for.
jmrker
01-06-2011, 08:55 PM
Those boxes are simple list boxes created in Acrobat that have export values based on pricing and duration.
The membership begins code I posted and the end membership text box is the one that is blank and I can't figure out anything for.
With only one line of code provided and not having the Acrobat program you refer to
I don't know what to help with. Sorry. :o
Philip M
01-07-2011, 07:43 AM
I would post your question in a more specialised Acrobat forum.