Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    List Box Durations to Calculate Date

    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"
    Attached Thumbnails Attached Thumbnails List Box Durations to Calculate Date-memdate.jpg  
    Last edited by alwclimbs; 01-05-2011 at 11:01 PM.

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,148
    Thanks
    39
    Thanked 506 Times in 500 Posts

    Question More information needed...

    Can you post some sample code of your problem so that we do not need to start from scratch?

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,316
    Thanks
    203
    Thanked 2,565 Times in 2,543 Posts
    This should do the trick.

    Code:
    <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."

  • #4
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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...

  • #5
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,148
    Thanks
    39
    Thanked 506 Times in 500 Posts
    Quote Originally Posted by alwclimbs View Post
    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?

  • #6
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #7
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,148
    Thanks
    39
    Thanked 506 Times in 500 Posts

    Arrow

    Quote Originally Posted by alwclimbs View Post
    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.

  • #8
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,316
    Thanks
    203
    Thanked 2,565 Times in 2,543 Posts
    I would post your question in a more specialised Acrobat forum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •