[英]Submit Button won't appear
更新:這是到目前為止的代碼。 現在出現下載按鈕,但是代碼正在打印表單結束標簽,而不是將其標識為結束標簽。 我該如何糾正? 請幫忙。 提前致謝!!
<HTML>
<HEAD>
<meta charset="utf-8">
<link rel="stylesheet" href="css/style2.css">
<TITLE>SAE Report</TITLE>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$().ready(function() {
$(".datepicker").datepicker({dateFormat:'yy-mm-dd'});
});
</script>
</HEAD>
<BODY>
<center>
<h1>SAE Report</h1>
</center>
<form action = "" method = "post">
<label>Report Type</label>
<select id="report" name="report">
<option value="none"></option>
<option value="new">New SAEs Report</option>
<option value="cumulative">Cumulative SAE Report</option>
</select>
<label>Start Date</label><input type="text" class="datepicker" name="start">
<label>End Date</label><input type="text" class="datepicker" name="end">
<input type="submit" name="submit" value="Submit">
</form>
</BODY>
<?php
$type='';
$start='';
$end='';
if (isset($_POST['submit'])){
$type=$_POST['report'];
$start=$_POST['start'];
$end=$_POST['end'];
if ($type=="cumulative"){
echo "<form action='cumulativeRptExcel.php' method='post' name ='xls'>";
echo "<input type='submit' name='submitXLS' value='Download Excel'/>";
echo "/form><br>";
echo "<form action='cumulativeRptPDF.php' method='post' name ='xls'>";
echo "<input type='submit' name='submitXLS' value='Download PDF'/>";
echo "/form><br>";
}
elseif($type=='new' and $start!='' and $end!=''){
echo "<form action='newRptExcel.php' method='post' name ='xls'>";
echo "<input type='submit' name='submitXLS' value='Download Excel'/>";
echo "/form><br>";
echo "<form action='newRptPDF.php' method='post' name ='xls'>";
echo "<input type='submit' name='submitXLS' value='Download PDF'/>";
echo "/form><br>";
}
elseif($type="new" and ($start=='' or $end=='')){
echo "You need to select START and END date for the report";
}
}
?>
report.php文件包含用於生成excel或pdf文件並將其下載給用戶的代碼。 單獨運行這些文件時,它會生成文件。
從以下位置更改您的提交按鈕:
<input type="submit" value="Submit">
至
<input type="submit" name="submit" value="Submit">
其背后的原因是$ _POST變量將僅包含在先前表單內具有名稱的元素。 在您的示例中,“提交”按鈕沒有名稱。
它打印/form>
因為您的代碼要求您打印它。 您回顯了"/form><br>";
而不是"</form><br>";
在我所看到的每一行中。 只需添加<
即可解決
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.