Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在提交时跳转到锚定-而不是页面顶部_Php_Html - Fatal编程技术网

Php 如何在提交时跳转到锚定-而不是页面顶部

Php 如何在提交时跳转到锚定-而不是页面顶部,php,html,Php,Html,在这个页面上,我有一个怀孕计算器脚本:。。。Itemid=104 目前,计算是按页面跳回顶部。我想把它放到锚上。知道我的意思吗?以下是脚本: 以下是根据您提供的信息得出的结果: 您的预计到期日为 请发布生成的HTML,而不是PHP。请尝试谢谢穆萨-非常感谢!!!应用此修补程序后我发现的另一个问题。现在“再次计算!”按钮开始工作。有什么想法吗?外面有人吗?有人能帮我吗?是不是因为我戴眼镜,所以没有人跟我说话?我将以任何愿意帮助我的人的名字来命名我的下一个孩子! <?php <?ph

在这个页面上,我有一个怀孕计算器脚本:。。。Itemid=104

目前,计算是按页面跳回顶部。我想把它放到锚上。知道我的意思吗?以下是脚本:



以下是根据您提供的信息得出的结果:

您的预计到期日为


请发布生成的HTML,而不是PHP。请尝试

谢谢穆萨-非常感谢!!!应用此修补程序后我发现的另一个问题。现在“再次计算!”按钮开始工作。有什么想法吗?外面有人吗?有人能帮我吗?是不是因为我戴眼镜,所以没有人跟我说话?我将以任何愿意帮助我的人的名字来命名我的下一个孩子!
<?php
<?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);

   ?>
   <div class="calculator_table">
   <p>Here are the results based on the information you provided:</p>
    <!-- <p>Your next <b>menstrual period</b> is expected to start on <strong><?php echo $next_period?></strong>.</p> -->
   <!--<p>You next <b>most fertile</b> period is <strong><?php echo $firstday?> to <?php echo $lastday?></strong>.</p> -->
   <p>Your estimated <b>due date</b> is <strong><?php echo $duedate?></strong>.</p>
   <p align="center"><input type="button" value="Calculate again!" onclick="window.location='http://<?php echo $_SERVER['HTTP_HOST'];?><?php echo $_SERVER['REQUEST_URI']?>'"></p>
   </div>
<?php else:
   //the calculator comes here
   ?>
   <div class="calculator_table">
   <form method="post">
     <p>Please select the first day of your last menstrual period:</p>
   <p><?php echo date_chooser("date",date("Y-m-d"))?></p>
   <p>Usual number of days in your period: <select name="days">
   <?php
   for($i=20;$i<=45;$i++)
   {
      if($i==28) $selected='selected="true"';
      else $selected='';
      echo "<option $selected value='$i'>$i</option>";
   }
   ?>
   </select></p>
   <p align="center"><input type="submit" name="calculator_ok" value="Calculate"></p>
   </form>
   </div>
<?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.="<select name='".$name."month'>";
   for($i=1;$i<=12;$i++)
   {
      if($i==$month) $selected='selected="true"';
      else $selected='';
      $chooser.="<option $selected value='$i'>$months[$i]</option>";
   }
   $chooser.="</select> / ";

   $chooser.="<select name='".$name."day'>";
   for($i=1;$i<=31;$i++)
   {
      if($i==$day) $selected='selected';
      else $selected='';
      $chooser.="<option $selected value='$i'>$i</option>";
   }
   $chooser.="</select> / ";

   $chooser.="<select name='".$name."year'>";
   for($i=(date("Y")-1);$i<=2050;$i++)
   {
      if($i==$year) $selected='selected';
      else $selected='';
      $chooser.="<option $selected>$i</option>";
   }
   $chooser.="</select> ";   

   return $chooser;
}
?>