www.webdeveloper.com
Results 1 to 2 of 2

Thread: display one year from first textbox in second textbox

Hybrid View

  1. #1
    Join Date
    Jul 2013
    Posts
    6

    Question display one year from first textbox in second textbox

    I have two textboxes in a form. The first textbox contains a calender. I would like to display after one year date in second text box based on the calender date selected in first text box. How to achieve this? I only know about getting the current textbox value but not how to put after one year date in second textbox.



    PHP Code:
    <td><input type="text" name="soname3" id="id1" size="15"
         <
    img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('id1','MMddyyyy','dropdown',false,'12')" /></td>
        
        <
    td><input type="text" name="" id="id2" size="20"> </td

  2. #2
    Join Date
    Jul 2013
    Posts
    6
    I tried the below code, it worked with onblur. But if I use the calender, then the second textbox value doesn't change. How to get it changes automatically once the value from calender is selected.




    <script>
    function addDays(theField,fName,daysToAdd){
    var theForm = theField.form;
    var fDate = new Date(theField.value);
    fDate.setDate(fDate.getDate()+daysToAdd);
    var MM = fDate.getMonth()+1;
    var DD = fDate.getDate();
    var YY = fDate.getFullYear();
    if(MM<10) MM="0"+MM;
    if(DD<10) DD="0"+DD;
    theForm[fName].value = MM+"-"+DD+"-"+YY;
    }
    onload=function(){addDays(document.forms[0].EffectiveDate,'90Days',365)};
    </script>
    </head>
    <body>
    <form>
    <input type=text id="id1" name="EffectiveDate" value="08-28-2005" size="10" onchange="addDays(this,'90Days',365)">
    <img src="../Image/cal.gif" id="" style="cursor: pointer;" onclick="javascript:NewCssCal('id1','MMddyyyy','dropdown',false,'12')" />

    <input type=text name="90Days" size="10">
    </form>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles