www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 18

Thread: pregnancy calculator script

Hybrid View

  1. #1
    Join Date
    Dec 2013
    Posts
    6

    pregnancy calculator script

    Hello I need your help in creating a script for that pregnancy calculator please

    http://www.duedatecalculator.org/free-calculator/

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,373
    So what is wrong with the script provided at the link?

  3. #3
    Join Date
    Dec 2013
    Posts
    6
    I want to translate it into my language

  4. #4
    Join Date
    Dec 2013
    Posts
    6
    I need it in Hebrew to add to my blog please

  5. #5
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,373
    Sorry, can not help
    Not a second language for me.

  6. #6
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,335
    40 to 42 weeks is considered the normal gestation period and from that you can extrapolate a basic script.

    The calculator uses a server-side script to perform its calculations but you can obtain an idea of the parameters by passing the script a number of parameters to obtain an idea of the algorithm that it is using.

    Using the following parameters...

    December 3 / 2013 and 28 days cycle the script outputs the following information.

    Your next menstrual period is expected to start on December 31, 2013.

    Your next most fertile period is December 15, 2013 to December 19, 2013.

    If you conceive within this timeframe, your estimated due date will be September 09, 2014.

    ======================

    So putting the data in to a spread sheet (for simplicity) I found that they were using 36 weeks as a guide which IMHO is not a good calculation and over simplistic because 252/28 = 9

    You have 90 days in a quarter ... 270 days is 9 months, not 252.

    I would say that the calculator has a fundamental flaw in two respects, firstly each pregnancy is different and baby comes when its due and the math behind the calculator is not as accurate as it could be.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  7. #7
    Join Date
    Nov 2002
    Location
    Flint, Michigan, USA
    Posts
    590
    Quote Originally Posted by IlonaK View Post
    Hello I need your help in creating a script for that pregnancy calculator please

    http://www.duedatecalculator.org/free-calculator/
    I did a similar calculator for a lady who was breeding horses, and then expanded the basic idea into a generalized date-jump page at http://spruce.flint.umich.edu/~jalarie/jaa_kch.htm.

    If you can give me the names of your months, the number of days in each, and what you feel is a normal gestation period, I can probably do something for you.

  8. #8
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,335
    In fact, in the time between the last post and this one, I have written a simple routine and also made a cup of coffee..
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  9. #9
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,335
    The simplicity of this should be a case of sign posting and letting the OP to get on with it themselves, if they want to learn JS then this is the best way, doing something for someone does not help that person learn does it?

    1. You need to grab a date, that would be best using a pull down menu of day / month / year
    2. you need to add at least 9 months 2 weeks to that date or rough it out to ((365 / 4) * 3)+14
    3 using the javascript setDate() function to add those number of days to the date object generated from the input, you can get a possible DOB.

    Job done, only thing needed is a nice header graphic and some CSS.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  10. #10
    Join Date
    Dec 2013
    Posts
    6
    Estimated Fertility between 10-20 days after "first day of last menstrual period"
    Estimated Conception Date between 14 days after "first day of last menstrual period"
    Estimated Due date 280 days or 40 weeks after "first day of last menstrual period"
    This is what I need
    For example:
    If first day of last menstrual period is: 1/12/13 (dd/mm/yy)
    so....
    Estimated Fertility: 10/12/13-20/12/13
    Estimated Conception Date: 14/12/13
    Estimated Due date: 07/09/14
    Unfortunately I do not know the language of JS, so I'm asking for your help!
    Thank you!

  11. #11
    Join Date
    Nov 2002
    Location
    Flint, Michigan, USA
    Posts
    590
    Quote Originally Posted by IlonaK View Post
    Estimated Fertility between 10-20 days ... Unfortunately I do not know the language of JS, so I'm asking for your help!
    Thank you!
    You gave most of what I need to give you help. I don't know the Hebrew month names nor the length of each. I seem to remember that Second-Adar gets to pop in and out "as needed" to really mess things up! I need the details on that.

  12. #12
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,335
    I am feeling pretty generous, as you are a beginner, try to work with this as a base and work out what you need to do to get the desired results, this is as close as you are going to get to what you want.

    Excuse the translations, you have google to thank for that.

    If you need help understanding any of it and why I went down this particular route / method then let me know what it is and I will answer as best I can so you can understand.

    The only proviso I have on this is you give some credit and the URL remains in the page.

    HTML Code:
    <!DOCTYPE>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>מחשבון הריון על ידי \ \. \</title>
    <style>
    textarea,select{direction:rtl;}
    </style>
    <script>
    /*
        Script on : 
        http://www.webdeveloper.com/forum/showthread.php?287245-pregnancy-calculator-script
        Based on original script by : \\.\
    */
    monthName = {	"Jan":"ינואר",
    				"Feb":"פברואר",
    				"Mar":"מרץ",
    				"Apr":"אפריל",
    				"May":"מאי",
    				"Jun":"יוני",
    				"Jul":"יולי",
    				"Aug":"אוגוסט",
    				"Sep":"ספטמבר",
    				"Oct":"אוקטובר",
    				"Nov":"נובמבר",
    				"Dec":"דצמבר"
    			}
    
    dow = {
    		"Sun":"יום ראשון",
    		"Mon":"יום שני",
    		"Tue":"יום שלישי",
    		"Wed":"יום רביעי",
    		"Thu":"יום חמישי",
    		"Fri":"יום שישי",
    		"Sat":"יום שבת"
    	}		
    		
    // get selected date
    
    function selectedDate(){
    // create a date string that the date object understands
    	with( document.dateValue ){
    		dateStr = [	dayMonth[ dayMonth.selectedIndex ].value,
    					monthName[ monthName.selectedIndex ].value,
    					yearSelect[ yearSelect.selectedIndex ].value
    				].join(" ");
    	}// end of with
    	
    res = new Date(dateStr+ " 00:00:00");
    conceive = res.toUTCString().slice(0,16);
    // gestation =
    gestation = ((365/4)*3)+14; // gets days
    
    res.setDate( gestation );
    birth = res.toUTCString().slice(0,16);
    
    
    // generate a message
    str = "בהנחה שאתה הגה במועד ניתנו כ "+conceive+" ותקופת ההריון שלך היא "+gestation+" ימים, המועד הצפוי של לידה יהיה סביב "+birth;
    // replace days of week and month names
    str = str.replace( conceive.slice(0,3),		dow[ conceive.slice(0,3) ] );
    str = str.replace( conceive.slice(8,11),	monthName[ conceive.slice(8,11) ] );
    str = str.replace( birth.slice(0,3),		dow[ birth.slice(0,3)] );
    str = str.replace( birth.slice(8,11),		monthName[ birth.slice(8,11) ] );
    
    document.dateValue.outputMessage.innerHTML = str;
    }
    </script>
    </head>
    <body>
      <form id="dateValue" name="dateValue" method="post" action="javascript:;" onSubmit="selectedDate(); return false;">
        <p>
          <select name="dayMonth">
            <option>1</option>
            <option>2</option>
            <option>3</option>
            <option>4</option>
            <option>5</option>
            <option>6</option>
            <option>7</option>
            <option>8</option>
            <option>9</option>
            <option>10</option>
            <option>11</option>
            <option>12</option>
            <option>13</option>
            <option>14</option>
            <option>15</option>
            <option>16</option>
            <option>17</option>
            <option>18</option>
            <option>19</option>
            <option>20</option>
            <option>21</option>
            <option>22</option>
            <option>23</option>
            <option>24</option>
            <option>25</option>
            <option>26</option>
            <option>27</option>
            <option>28</option>
            <option>29</option>
            <option>30</option>
            <option>31</option>
          </select>
          /      
          <select name="monthName">
            <option value="Jan">ינואר</option>
            <option value="Feb">פברואר</option>
            <option value="Mar">מרץ</option>
            <option value="Apr">אפריל</option>
            <option value="May">מאי</option>
            <option value="Jun">יוני</option>
            <option value="Jul">יולי</option>
            <option value="Aug">אוגוסט</option>
            <option value="Sep">ספטמבר</option>
            <option value="Oct">אוקטובר</option>
            <option value="Nov">נובמבר</option>
            <option value="Dec">דצמבר</option>
          </select>
          /      
          <select name="yearSelect">
            <option value="2013">2013</option>
            <option value="2014">2014</option>
            <option value="2015">2015</option>
          </select>
          <input type="submit" name="Submit" value="Submit" />
        </p>
        <p>
          <textarea name="outputMessage" cols="50" rows="3"></textarea>
    </p>
      </form>
    </body>
    </html>
    Is that any good to you?
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  13. #13
    Join Date
    Dec 2013
    Posts
    6
    Thank you! But the calculator is not accurate.
    I compare the different pregnancy calculator and the results are different.
    Overall difference between first menstrual date to Birth date is 280 days. Why you use 287.75 days?

  14. #14
    Join Date
    Dec 2013
    Posts
    6
    Nothing to be done
    Medicine Average gestational age is 40 weeks. Always count pregnancy by pregnancy wheel. Of course there are women who gives birth before / after this date (like me on 38 weeks!). That is why it is called "Estimated" date!
    jalarie thank you!!!

  15. #15
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,335
    pregnancies are not to the exact date and the average pregnancy is 9 months hence the 365 / 4 then * 3 = 9 months in days + 14 days to give a margin of error.

    Some reading for you... http://voices.yahoo.com/the-lie-edd-...u-1958162.html

    295 days according to this site.

    Its a case of using an average, baby will arrive when baby is ready.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

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