title: How to jump to anchor on submit - not to top of page
body: <p>On this page I have a pregnancy calculator script: <a href="http://taranakimidwife.co.nz/index.php" rel="nofollow">http://taranakimidwife.co.nz/index.php</a>? ... Itemid=104</p>
  
  <p>At present, calculate is press the page jumps back to the top. I want it to go to an the anchor #pregcalc. Know what I mean? This is the script:</p>
  
  <hr>
  
  <pre><code>&lt;?php
  &lt;?php if(!empty($_POST['calculator_ok'])):
     //last cycle date
     $date="$_POST[dateyear]-$_POST[datemonth]-$_POST[dateday]";
  
     //convert to time
     $lasttime=mktime(0,0,0,$_POST['datemonth'],$_POST['dateday'],$_POST['dateyear']);
  
      // next period start
      $next_period=$lasttime + $_POST['days']*24*3600;
      $next_period=date("F d, Y",$next_period);
  
     //first fertile day
     $firstdaytime=$lasttime + $_POST['days']*24*3600 - 16*24*3600;
     $firstday=date("F d, Y",$firstdaytime);
  
     //last fertile day
     $lastdaytime=$lasttime + $_POST['days']*24*3600 - 12*24*3600;
     $lastday=date("F d, Y",$lastdaytime);
  
     //have to adjust due date?
     $diff=$_POST['days'] - 28;
  
     //due date $date + 280 days
     $duedatetime=$lasttime + 280*24*3600 + $diff*24*3600;
     $duedate=date("F d, Y",$duedatetime);
  
     ?&gt;
     &lt;div class="calculator_table"&gt;
     &lt;p&gt;Here are the results based on the information you provided:&lt;/p&gt;
      &lt;!-- &lt;p&gt;Your next &lt;b&gt;menstrual period&lt;/b&gt; is expected to start on &lt;strong&gt;&lt;?php echo $next_period?&gt;&lt;/strong&gt;.&lt;/p&gt; --&gt;
     &lt;!--&lt;p&gt;You next &lt;b&gt;most fertile&lt;/b&gt; period is &lt;strong&gt;&lt;?php echo $firstday?&gt; to &lt;?php echo $lastday?&gt;&lt;/strong&gt;.&lt;/p&gt; --&gt;
     &lt;p&gt;Your estimated &lt;b&gt;due date&lt;/b&gt; is &lt;strong&gt;&lt;?php echo $duedate?&gt;&lt;/strong&gt;.&lt;/p&gt;
     &lt;p align="center"&gt;&lt;input type="button" value="Calculate again!" onclick="window.location='http://&lt;?php echo $_SERVER['HTTP_HOST'];?&gt;&lt;?php echo $_SERVER['REQUEST_URI']?&gt;'"&gt;&lt;/p&gt;
     &lt;/div&gt;
  &lt;?php else:
     //the calculator comes here
     ?&gt;
     &lt;div class="calculator_table"&gt;
     &lt;form method="post"&gt;
       &lt;p&gt;Please select the first day of your last menstrual period:&lt;/p&gt;
     &lt;p&gt;&lt;?php echo date_chooser("date",date("Y-m-d"))?&gt;&lt;/p&gt;
     &lt;p&gt;Usual number of days in your period: &lt;select name="days"&gt;
     &lt;?php
     for($i=20;$i&lt;=45;$i++)
     {
        if($i==28) $selected='selected="true"';
        else $selected='';
        echo "&lt;option $selected value='$i'&gt;$i&lt;/option&gt;";
     }
     ?&gt;
     &lt;/select&gt;&lt;/p&gt;
     &lt;p align="center"&gt;&lt;input type="submit" name="calculator_ok" value="Calculate"&gt;&lt;/p&gt;
     &lt;/form&gt;
     &lt;/div&gt;
  &lt;?php endif;
  
  //to print a date chooser - get name and value in mysql date format
  function date_chooser($name,$value="")
  {
     $months=array('','January','February','March','April','May','June','July','August',
     'September','October','November','December');
  
     if(empty($value)) $value=date("Y-m-d");
  
     $parts=explode("-",$value);
  
     $day=$parts[2]+0;
     $month=$parts[1]+0;
     $year=$parts[0];
  
     $chooser="";
  
     $chooser.="&lt;select name='".$name."month'&gt;";
     for($i=1;$i&lt;=12;$i++)
     {
        if($i==$month) $selected='selected="true"';
        else $selected='';
        $chooser.="&lt;option $selected value='$i'&gt;$months[$i]&lt;/option&gt;";
     }
     $chooser.="&lt;/select&gt; / ";
  
     $chooser.="&lt;select name='".$name."day'&gt;";
     for($i=1;$i&lt;=31;$i++)
     {
        if($i==$day) $selected='selected';
        else $selected='';
        $chooser.="&lt;option $selected value='$i'&gt;$i&lt;/option&gt;";
     }
     $chooser.="&lt;/select&gt; / ";
  
     $chooser.="&lt;select name='".$name."year'&gt;";
     for($i=(date("Y")-1);$i&lt;=2050;$i++)
     {
        if($i==$year) $selected='selected';
        else $selected='';
        $chooser.="&lt;option $selected&gt;$i&lt;/option&gt;";
     }
     $chooser.="&lt;/select&gt; ";   
  
     return $chooser;
  }
  ?&gt;
  </code></pre>