js动态增加表单页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#main {
height: 650px;
width: 800px;
margin-top: 5px;
margin-right: auto;
margin-left: auto;
}
#main strong {
letter-spacing: 2px;
font-size: 18px;
}
#main strong a {
text-decoration: none;
}
#main #form1 table tr td {
line-height: 25px;
}
#main #form1 table tr th {
height: 25px;
}
#main #form1 table tr td #button {
width: 50px;
}
#main #form1 table tr td #button2 {
width: 50px;
}
.td{
background-color: #FFE;
height: 30px;
}
.tds{
background-color: #CCC;
height: 30px;
}
#main #form1 table tr .td #textfield2 {
width: 125px;
}
#main #form1 table tr .td #textfield3 {
width: 125px;
}
#main #form1 table tr .td #textfield4 {
width: 125px;
}
#main #form1 table tr .td #textfield5 {
width: 125px;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
var i=0
function Add1()
{
var temp=document.getElementById("add")
temp.insertRow(temp.rows.length);
temp.rows.item(temp.rows.length -1).insertCell(0);
var xx=temp.rows.length -1 ;//-1
var sHTML
sHTML='<TABLE border=\"1\" style=\"border-collapse: collapse\" bordercolor=\"#111111\"width=\"100%\">' +
'<TR>' +
'<TD align=\"left\" width="25%"><SELECT NAME=\"\">'+
'<option value=\"0\"> ------------------- </option>'+
'<option value=\"1\"> 海马高度 </option>' +
'<option value=\"2\"> 脉络膜裂宽度 </option>' +
'<option value=\"3\"> 内嗅皮层厚度 </option>' +
'<option value=\"4\"> 颞叶干宽度 </option>' +
'<option value=\"5\"> 侧裂池宽度 </option>' +
'<option value=\"6\"> 海马total NAA/CR </option>' +
'<option value=\"7\"> 海马total MI/CR </option>' +
'<option value=\"8\"> 头NAA/CR </option>' +
'<option value=\"9\"> 头MI/CR </option>' +
'<option value=\"10\"> 体NAA/CR </option>' +
'<option value=\"11\"> 体MI/CR </option>' +
'<option value=\"12\"> 尾NAA/CR </option>' +
'<option value=\"13\"> 尾MI/CR </option>' +
'<option value=\"14\"> 杏仁核NAA/CR </option>' +
'<option value=\"15\"> 杏仁核MI/CR </option>' +
'<option value=\"16\"> 扣带回NAA/CR </option>' +
'<option value=\"17\"> 扣带回MI/CR </option>' +
'</SELECT>' +
'</TD>' +
'<TD align=\"left\" width="65%"> 左侧: <input type=\"text\" name=\"\"> 右侧: <input type=\"text\" name=\"\"></TD>' +
'<TD align=\"center\" width="10%"><input type=\"button\" value=\" 删除 \" onclick=\"Delete(this);\"></TD>'+
'</TR>' +
'</TABLE>';
temp.rows.item(temp.rows.length-1).cells.item(0).innerHTML=sHTML;
temp.rows.item(temp.rows.length-1).cells.item(0).children.item(0).rows.item(0).cells.item(2).children.item(0).text=xx;
temp.rows.item(temp.rows.length-1).cells.item(0).children.item(0).rows.item(0).cells.item(0).children.item(0).name="seeo"+xx;
temp.rows.item(temp.rows.length-1).cells.item(0).children.item(0).rows.item(0).cells.item(1).children.item(0).name="seeo"+xx+"L";
temp.rows.item(temp.rows.length-1).cells.item(0).children.item(0).rows.item(0).cells.item(1).children.item(1).name="seeo"+xx+"R";
}
function Add2()
{
var temp=document.getElementById("add1")
temp.insertRow(temp.rows.length);
temp.rows.item(temp.rows.length -1).insertCell(0);
var xx=temp.rows.length -1 ;//-1
var sHTML
sHTML='<TABLE border=\"1\" style=\"border-collapse: collapse\" bordercolor=\"#111111\"width=\"100%\">' +
'<TR>' +
'<TD align=\"left\" width="25%" ><input type=\"text\" name=\"\"></TD>' +
'<TD align=\"left\" width="65%"> 左侧: <input type=\"text\" name=\"\"> 右侧: <input type=\"text\" name=\"\"></TD>' +
'<TD align=\"center\" width="10%"><input type=\"button\" value=\" 删除 \" onclick=\"Delete2(this);\"></TD>'+
'</TR>' +
'</TABLE>';
temp.rows.item(temp.rows.length-1).cells.item(0).innerHTML=sHTML;
temp.rows.item(temp.rows.length-1).cells.item(0).children.item(0).rows.item(0).cells.item(2).children.item(0).text=xx;
temp.rows.item(temp.rows.length-1).cells.item(0).children.item(0).rows.item(0).cells.item(0).children.item(0).name="seei"+xx;
temp.rows.item(temp.rows.length-1).cells.item(0).children.item(0).rows.item(0).cells.item(1).children.item(0).name="seei"+xx+"L";
temp.rows.item(temp.rows.length-1).cells.item(0).children.item(0).rows.item(0).cells.item(1).children.item(1).name="seei"+xx+"R";
}
function Delete(x)
{
var temp=document.getElementById("add")
temp.deleteRow(x.text.valueOf())
for (var j=0;j<temp.rows.length;j++) {
temp.rows.item(j).cells.item(0).children.item(0).rows.item(0).cells.item(2).children.item(0).text=j;
temp.rows.item(j).cells.item(0).children.item(0).rows.item(0).cells.item(0).children.item(0).name="seeo"+j;
temp.rows.item(j).cells.item(0).children.item(0).rows.item(0).cells.item(1).children.item(0).name="seeo"+j+"L";
temp.rows.item(j).cells.item(0).children.item(0).rows.item(0).cells.item(1).children.item(1).name="seeo"+j+"R";
}}
function Delete2(x)
{
var temp=document.getElementById("add1")
temp.deleteRow(x.text.valueOf())
for (var j=0;j<temp.rows.length;j++) {
temp.rows.item(j).cells.item(0).children.item(0).rows.item(0).cells.item(2).children.item(0).text=j;
temp.rows.item(j).cells.item(0).children.item(0).rows.item(0).cells.item(0).children.item(0).name="seei"+j;
temp.rows.item(j).cells.item(0).children.item(0).rows.item(0).cells.item(1).children.item(0).name="seei"+j+"L";
temp.rows.item(j).cells.item(0).children.item(0).rows.item(0).cells.item(1).children.item(1).name="seei"+j+"R";
}}
</SCRIPT>
</head>
<body>
<div id="main">
<br>
<strong><a href="<?php echo $this->baseUrl?>/<?php echo $this->show?>">病人信息</a>|<a href="<?php echo $this->baseUrl?>/<?php echo $this->search?>">查找病人</a>|<a href="<?php echo $this->baseUrl?>/<?php echo $this->add?>">添加病人 </a>|<a href="<?php echo $this->baseUrl?>/<?php
echo $this->medreport?>">病历检索 </a>
</strong>
<form id="form1" name="form1" method="post" action="<?php echo $this->searchform?>">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<th colspan="2" align="left" scope="col">病人信息:</th>
</tr>
<tr>
<td width="18%" class="td">姓名:</td>
<td width="82%" class="td"><label for="textfield"></label>
<input type="text" name="name" id="textfield" /></td>
</tr>
<tr>
<td class="td">性别:</td>
<td class="td"><input type="radio" name="sex" id="radio" value="男" />
<label for="radio"> 男
<input type="radio" name="sex" id="radio2" value="女" />
女</label></td>
</tr>
<tr>
<td class="td">年龄:</td>
<td class="td"><label for="select"></label>
<select name="age" id="select">
<option value=0 selected="selected">--------------</option>
<option value=1 >0-5</option>
<option value=2 >6-15</option>
<option value=3 >16-30</option>
<option value=4 >31-60</option>
<option value=5 >61-</option>
</select></td>
</tr>
<tr>
<th colspan="2" align="left">检查信息: <INPUT TYPE="button" value="增添(选择项)" onclick="Add1()">
<INPUT TYPE="button" value="增添(填写项)" onclick="Add2()">
<span style="color: #F00">[注:建议使用“增添(选择项)”,搜索更快,更准确]</span></th>
</tr>
<tr>
<td colspan="2" align="center" class="td">
<table align=center border=0 width="100%" height="100%">
<tr>
<td width="100%" height="220" align="center">
<div style=" OVERFLOW: auto;BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid; WIDTH: 100%; HEIGHT: 100%">
<table width="100%" id="add">
</table>
<table width="100%" id="add1">
</table>
</div>
</td>
</tr>
</table>
<td>
</tr>
<tr>
<th colspan="2" align="left" scope="col" >诊断结果:</th>
</tr>
<tr>
<td colspan="2" align="left" class="td">
<input type="text" name="result1" id="textfield2" />
<select name="result12" id="select2">
<option value="and"> and </option>
<option value="or"> or </option>
</select>
<input type="text" name="result2" id="textfield3" />
<select name="result23" id="select3">
<option value="and"> and </option>
<option value="or"> or </option>
</select>
<input type="text" name="result3" id="textfield4" />
<select name="result34" id="select4">
<option value="and"> and </option>
<option value="or"> or </option>
</select>
<input type="text" name="result4" id="textfield5" /></td>
</tr>
<tr>
<td colspan="2" align="left"><input type="hidden" name="medreport_search" value="search">
<input type="submit" name="button" id="button" value="提交" /> <input type="reset" name="button2" id="button2" value="重置" />
</td></tr>
</table>
</form>
</div>
</body>
</html>
后台接收数据:
if(isset($_POST["medreport_search"])&&($_POST["medreport_search"]=="search"))
{
session_unset();
foreach ($_POST as $key=>$value)
$_SESSION[$key]=$value;
}
如果将session_unset();改为unset($_SESSION),则,页面刷新后,$_SESSION的各项值都被删除,这是为什么?刷新页面的时候,if条件块明明不能执行的。
另外,我们可以这样取出$_SESSION里的值。
如$i=1;
$_SESSION["seeo".$i]