我已经制作了 2 个 php 页面。一页是“doc.php”,另一页是“chkval.php”。我使用了一些 javascript 代码在“doc.php”中生成文本字段。通过使用 $POST ,我试图在“chkval.php”页面中捕获文本字段值,但文本字段值没有被错误捕获
使用未定义的常量 regCardRecp - 在第 3 行 regCardRecp 的 D:\wamp\www\chkval.php 中假定为“regCardRecp”
以下是我的完整代码。
文档.php
<html>
<head>
<title>Record Entry</title>
<script type="text/javascript">
window.onload = function()
{
var select = document.getElementById("select");
var texts = document.getElementById("texts");
select.onchange = function()
{
var val = select.options[select.selectedIndex].value;
texts.innerHTML = "";
if(val==9 ){
texts.innerHTML += '<div>Reg Card Reception Date (SSC): <input type="text" name="regCardRecp" id="regCardRecp"></div>'
texts.innerHTML += '<div>Reg Card Issue Date (SSC):<input type="text" name="regCardIss" id="regCardIss">'
texts.innerHTML += '<div>Roll no Slip Reception Date (SSC):<input type="text" name="rollSlipRecp" id="rollSlipRecp"></div>'
texts.innerHTML += '<div>Roll no Slip Issue Date (SSC):<input type="text" name="rollSlipIss" id="rollSlipIss"></div>'
texts.innerHTML += '<div>Marks Sheet Reception Date (SSC-I):<input type="text" name="marksheetRecpI" id="marksheetRecpI"/></div>'
texts.innerHTML += '<div>Marks Sheet Issue Date (SSC-I):<input type="text" name="marksheetIssI" id="marksheetIssI"/></div>'
texts.innerHTML += '<div>Result (SSC-I):<input type="radio" name="Sresult" value="pass" /> Pass<input type="radio" name="Sresult" value="fail" /> Fail</div>'
}
if(val==10 ){
texts.innerHTML += '<div>Marks Sheet Reception Date (SSC-II):<input type="text" name="marksheetRecpII" id="marksheetRecpII"></div>'
texts.innerHTML += '<div>Marks Sheet Issue Date (SSC-II):<input type="text" name="marksheetIssII" id="marksheetIssII"></div>'
texts.innerHTML += '<div>Certificate Reception Date (SSC):<input type="text" name="certRecp" id="certRecp"></div>'
texts.innerHTML += '<div>Certificate Issue Date (SSC):<input type="text" name="certIss" id="certIss"></div>'
texts.innerHTML += '<div>Result (SSC-II):<input type="radio" name="Sresult1" value="pass" /> Pass<input type="radio" name="Sresult1" value="fail" /> Fail</div>'
// texts.innerHTML += '<div></div>'
};
if( val==11){
texts.innerHTML += '<div>Reg Card Reception Date (HSSC):<input type="text" name="HhregCardRecp" id="HregCardRecp"></div>'
texts.innerHTML += '<div>Reg Card Issue Date (HSSC):<input type="text" name="HregCardIss" id="HregCardIss">'
texts.innerHTML += '<div>Roll no Slip Reception Date (HSSC):<input type="text" name="HrollSlipRecp" id="HrollSlipRecp"></div>'
texts.innerHTML += '<div>Roll no Slip Issue Date (HSSC):<input type="text" name="HrollSlipIss" id="HrollSlipIss"></div>'
texts.innerHTML += '<div>Marks Sheet Reception Date (HSSC-I):<input type="text" name="HmarksheetRecpI" id="HmarksheetRecpI"></div>'
texts.innerHTML += '<div>Marks Sheet Issue Date (HSSC-I):<input type="text" name="HmarksheetIssI" id="HmarksheetIssI"></div>'
texts.innerHTML += '<div>Result (HSSC-I):<input type="radio" name="Hresult" value="pass" /> Pass<input type="radio" name="Hresult" value="fail" /> Fail</div>'
};
if(val==12 ){
texts.innerHTML += '<div>Marks Sheet Reception Date (HSSC-II):<input type="text" name="HmarksheetRecpII" id="HmarksheetRecpII"></div>'
texts.innerHTML += '<div>Marks Sheet Issue Date (HSSC-II):<input type="text" name="HmarksheetIssII" id="HmarksheetIssII"></div>'
texts.innerHTML += '<div>Certificate Reception Date (HSSC):<input type="text" name="HcertRecp" id="HcertRecp"></div>'
texts.innerHTML += '<div>Certificate Issue Date (HSSC):<input type="text" name="HcertIss" id="HcertIss"></div>'
texts.innerHTML += '<div>Result (HSSC-II):<input type="radio" name="Hresult1" value="pass" /> Pass<input type="radio" name="Hresult1" value="fail" /> Fail</div>'
};
}
}
</script>
</head>
<body>
<form id="myform" method="post" action="chkval.php" onSubmit="chkval.php">
<h1 align="center">Documents Record Entry</h1>
<table width=50% align = 'center'>
<tr><td>Session:</td><td>
<select name="session">
<option value="19">19</option>
<option value="20">20</option>
</select>
<select name="session">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
</select>
-
<select name="session">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
</select>
</td></tr>
<tr>
<td>
Name:
</td>
<td>
<input type="text" name="name" id="name">
</td>
<td>
Board:
</td>
<td>
<input type="text" name="board" id="board">
</td>
</tr>
<tr><td>Class:</td><td>
<select id="select" size="1" name="class" >
<option value="1" >1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">Matric-I</option>
<option value="10">Matric-II</option>
<option value="11" >HSSC-I</option>
<option value="12">HSSC-II</option>
<option value="13">Bachelor</option>
</select>
<hr/>
<div id="texts"></div></td></tr>
<td>
</td>
<br>
</td>
<tr><td>Remarks:<textarea name="remarks" cols="24" rows="3"></textarea></td></tr>
<td>
<input type="submit" name="submit" value="Submit">
</td>
</tr>
</table>
</form>
</body>
</html>
chkval.php
<?php
$regCardRecp = $_POST['regCardRecp'];
echo(regCardRecp);
?>
任何帮助将不胜感激..谢谢