Note that there are some explanatory texts on larger screens.

plurals
  1. POAge calculator does not show computed age
    primarykey
    data
    text
    <p>This code is for computation of age based on the Selected Value of the user using the combo box and it must display the age in the text box provided below. The age must refreshed every time the user changes selected value in the combo box. but my current code does not the computed age does not show.</p> <pre><code>&lt;?php $month = date("m"); //without leading zero(o) $year = date("Y"); //four digit format $day = date("d"); $st_year = "1950"; //Starting Year $month_names = array("January", "February", "March","April", "May", "June", "July", "August", "September", "October", "November", "December"); ?&gt; &lt;form name="Month_Year" id="Month_Year" method="post"&gt; &lt;select name="month" id="month"&gt; &lt;?php for ($i=1; $i&lt;=12; $i++) { echo "&lt;option "; if ($i == $month) { echo "selected=\"selected\" "; } echo "value=\"$i\"&gt;", $month_names[$i-1], "&lt;/option&gt;\n"; } ?&gt; &lt;/select&gt; &lt;select name="year" id="year"&gt; &lt;?php for ($i=$st_year; $i&lt;=$year; $i++) { echo "&lt;option "; if ($i == $year) { echo "selected=\"selected\" "; } echo "value=\"$i\"&gt;$i&lt;/option&gt;\n"; } ?&gt; &lt;/select&gt; &lt;select name="day" id="day"&gt; &lt;?php for ($i=1; $i&lt;=31; $i++) { echo "&lt;option&gt; "; if ($i == $day) { echo "selected=\"selected\" "; } echo "value=\"$i\"&gt;$i&lt;/option&gt;\n"; } ?&gt; &lt;/select&gt; // I used this code to combine the selected value in the combo box. &lt;?php $Convertdays = $month."/".$day."/".$year; echo $Convertdays; ?&gt; &lt;script type="text/javascript"&gt; var birth = new Date( &lt;?php '$Convertdays'?&gt;); var check = new Date(); var milliDay = 1000 * 60 * 60 * 24; // a day in milliseconds; var ageInDays = (check - birth) / milliDay; var ageInYears = Math.floor(ageInDays / 365 ); var age = ageInDays / 365 ; &lt;/script&gt; </code></pre> <p>Every time I change the value of the combo box, the textbox displays 0. Lets assume that the values of the Textboxes are October 19 1991 it should display 21</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload