View Single Post
Old 12-23-2012, 11:14 PM   PM User | #2
jalarie
Regular Coder

 
Join Date: Jun 2002
Location: Flint, Michigan, USA
Posts: 593
Thanks: 1
Thanked 19 Times in 19 Posts
jalarie is an unknown quantity at this point
Maybe this will help:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
  <head>

    <title>Medicine Supply</title>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Script-Type" content="text/javascript" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <meta http-equiv="Content-Language" content="en-US" />
    <meta name="Author" content="James Alarie - jalarie@umich.edu" />
    <meta name="description" content="Calculate the day on which the medication supply runs out." />
    <meta name="keywords" content="calculate,day,medication,supply" />
    
    <script type="text/javascript">
      /*<![CDATA[*/

  function ComputeIt() {
    f1=document.forms[0];                           // abbreviation
    
    I_StartDate       =f1.F_StartDate.value;
    I_AvailableTablets=f1.F_AvailableTablets.value;
    I_NumberPerDayI   =f1.F_NumberPerDay.selectedIndex;
    I_NumberPerDay    =f1.F_NumberPerDay.options[I_NumberPerDayI].value;
    
    S_StartDate=new Date(I_StartDate)*1;            // milliseconds since 1970-01-01
    S_StartDate=S_StartDate/(24*60*60*1000);        // ...days as a decimal
    S_StartDate=Math.floor(S_StartDate);            // ...days integer
    S_Days=Math.floor(I_AvailableTablets/I_NumberPerDay);
    S_OutOfSupplyAfter=S_StartDate*1+S_Days*1-1;
    
    S_Date=new Date((S_OutOfSupplyAfter*1+1)*24*60*60*1000);
    S_Year =S_Date.getFullYear();
    S_Month=S_Date.getMonth()*1+1;                  // month as 1-12
    S_Date =S_Date.getDate();
    
    O_Date=S_Year+'-'+S_Month+'-'+S_Date;
    f1.F_OutOfSupplyAfter.value=O_Date;
    
    return true;
  } // ComputeIt

      /*]]>*/
    </script>

  </head>

  <body class="body1">
   <div id="body">
<!-- Page Header -->
    <div id="header">
      <h1>Medicine Supply</h1>
      <hr />
    </div>

<!-- Content -->
    <div id="content">
      <br />
      <noscript>
        <p class="notice">
          You must have scripting enabled to make full use of this page.
        </p>
      </noscript>
      
      <div class="center">
        <form method="post" action="javascript:void(0);">
         <div class="form">
          <table border="1" cellspacing="2" cellpadding="2"
              summary="This table is used for layout purposes only.">
            <caption class="caption2"><b>Medication Supply</b></caption>
            <tbody>
              <tr>
                <td>
                  <label for="F_StartDate">Start Date</label>
                </td>
                <td>
                  <input type="text" size="20" value="?" name="F_StartDate" id="F_StartDate" alt="First date" onfocus="this.select();" />
                </td>
                <td>
                  as YYYY-MM-DD
                </td>
              </tr>
              <tr>
                <td>
                  <label for="F_AvailableTablets">Available Tablets</label>
                </td>
                <td>
                  <input type="text" size="20" value="?" name="F_AvailableTablets" id="F_AvailableTablets" alt="Number of Available Tablets" onfocus="this.select();" />
                </td>
                <td>
                  Enter the number of tablets that you have
                </td>
              </tr>
              <tr>
                <td>
                  <label for="F_NumberPerDay">Number per Day</label>
                </td>
                <td>
                  <select name="F_NumberPerDay" id="F_NumberPerDay">
                    <option>1</option>
                    <option>2</option>
                  </select>
                </td>
                <td>
                  How many do you take each day?
                </td>
              </tr>
              <tr>
                <td colspan="3">
                  <input type="button" value="Compute" onclick="ComputeIt();" />&nbsp; 
                  <input type="reset" value="Reset" title="Reset" />&nbsp; 
                </td>
              </tr>
              <tr>
                <td>
                  <label for="F_OutOfSupplyAfter">Out of Supply After</label>
                </td>
                <td>
                  <input type="text" size="20" value="?" name="F_OutOfSupplyAfter" id="F_OutOfSupplyAfter" alt="Take the last Tablet on this Date" onfocus="this.select();" />
                </td>
                <td>
                  result:&nbsp; take the last tablet on this date
                </td>
              </tr>
            </tbody>
          </table>
         </div><!-- form -->
        </form>
        
      </div><!-- center -->
  
    </div>
  
<!-- Page Footer -->
    <div id="footer">
      <br clear="all" /><hr />
      Written on December 23, 2012, by:&nbsp;
      <a href="mailto:jalarie@umich.edu">James Alarie</a>.
    </div>

   </div>
  </body>

</html>
__________________
Visit my site at http://spruce.flint.umich.edu/~jalarie/.
jalarie is offline   Reply With Quote