这个是点击A页面文本框弹出的画面<?php include("../db/dbconnect.php");//连接数据库///////////////////////////////////////以下是查詢分頁 $sql="select _roominfo.roomno,_roominfo.location,_bedinfo.* from _roominfo,_bedinfo where _roominfo.id=_bedinfo.rid and occuption='".$no."'"; //联表查询 $result=mysql_query($sql); $pagesize=10;//每页10条记录 $total=mysql_num_rows($result); $filename="roominfoselect.php?";
for($i=0;$i<$count;$i++) { $sql3="select * from _roominfo,_bedinfo where _roominfo.id=_bedinfo.rid and _bedinfo.id='$id[$i]'"; $_SESSION['bid']=$id[$i]; }
弹出一个层的话可能更好处理一些,这样只处理当前页面.
include("../db/dbconnect.php");//连接数据库///////////////////////////////////////以下是查詢分頁
$sql="select _roominfo.roomno,_roominfo.location,_bedinfo.* from _roominfo,_bedinfo where _roominfo.id=_bedinfo.rid and occuption='".$no."'"; //联表查询
$result=mysql_query($sql); $pagesize=10;//每页10条记录 $total=mysql_num_rows($result);
$filename="roominfoselect.php?";
$currpage=intval($_REQUEST["page"]);
if(!is_int($currpage))
$currpage=1;
if(intval($currpage)<1)$currpage=1;
if(intval($currpage-1)*$pagesize>$total)$currpage=1;
if(($total%$pagesize)==0)
{
$totalpage=intval($total/$pagesize);
}
else
$totalpage=intval($total/$pagesize)+1;
if ($total!=0&&$currpage>1)
mysql_data_seek($result,(($currpage-1)*$pagesize)); $i=0;
///////////////////////////////////////////////////////////////////////////////////////
?>
<style type="text/css">
<!--
.STYLE3 {font-size: x-small}
.STYLE4 {font-size: x-small; color: #0000FF; }
-->
</style>
<body bgcolor="#d4d0c8"><style type="text/css">
<!--
.STYLE2 {font-size: x-small}
-->
</style><form name="room_form" method="post" action="../staff/Basicinfo.php?action=add" >
<table width="314" height="94" border="1" cellpadding="0" cellspacing="0">
<tr>
<td height="27" colspan="4"><div align="center"><strong>可入住房間床號資料</strong></div><A href="#" onClick="uu()"></A></td>
</tr>
<tr>
<td height="21" colspan="4"><div align="center" class="STYLE4">請勾選複選框點擊確定!</div></td>
</tr>
<tr >
<td height="21" colspan="2"><label></label> <div align="center">房間號</div></td>
<td colspan="2"><label>
<div align="center">床號</div>
</label></td>
</tr>
<?php while($row=mysql_fetch_array($result))
{
$i++;
if($i>$pagesize)break;
?>
<tr onMouseOver=this.style.backgroundColor='#000000' onMouseOut=this.style.backgroundColor=''>
<td width="20" height="23"><input type="checkbox" name="txtid[]" value="<? echo $row['id']; ?>"></td>
<td width="106"><label>
<input id="txtroomno" name="txtroomno" type="text" size="15" value="<? echo $row['roomno']; ?>" readonly="" >
</label></td>
<td width="108"><input id="txtbedno" name="txtbedno" type="text" size="15" value="<? echo $row['bedno']; ?>" readonly=""></td>
<td width="70"><input type="submit" name="oper2" value="確定" onClick="ref()" ></td>
</tr>
<? } ?>
</table>
</form><!-- 这里插入分页的页脚,插入while之后,一般可以在</table>下边-->
<form method="post" action="<?php echo $filename;?>">
<span class="STYLE3">共
<?php echo $total;?>
个记录 <?php
if($currpage==1){
?>
首页 上一页
<?php
} else {
?>
<a href=<?php echo $filename;?>page=1>首页</a> <a href=<?php echo $filename;?>page=<?php echo ($currpage-1);?>>上一页</a>
<?php }if($currpage==$totalpage){
?>
下一页 尾页
<?php }else{?><a href=<?php echo $filename;?>page=<?php echo ($currpage+1);?>>下一页</a> <a href=<?php echo $filename;?>page=<?php echo $totalpage;?>>尾页</a> <?php }?>
</span>
<select name='page' size='1' onchange='javascript:submit()' action='<?php echo $filename;?>'>
<?php
for($i=1;$i<=$totalpage;$i++)
{
?>
<option value=<?php echo $i; ?>
<?php
if ($currpage==$i)
echo "selected";
?>>
第<?php echo $i;?>页</option> <?php }?>
</select>
</form></body>
<?php
$oper2=$_POST['oper2'];
$id=$_POST['txtid'];
if($oper2=="確定"){if($id!="")
{
$count=count($id);
if($count>=2)
{
echo"<script>alert('對不起,您只能勾選一個!');location.href='roominfoselect.php';</script>";
}else
{
for($i=0;$i<$count;$i++)
{
$sql3="select * from _roominfo,_bedinfo where _roominfo.id=_bedinfo.rid and _bedinfo.id='$id[$i]'";
$_SESSION['bid']=$id[$i];
}
$rs3=mysql_query($sql3);
$row3=mysql_fetch_array($rs3);
$_SESSION['roomno']=$row3['roomno'];
$_SESSION['bedno']=$row3['bedno'];
echo $_SESSION['bid']; //点击确定选择从数据库查到的id,房号和床号保存在
echo $_SESSION['roomno']; //session里
echo $_SESSION['bedno'];
}
}else
{
echo"<script>alert('對不起,您還沒有勾選資料!');location.href='roominfoselect.php';</script>";
}
}
?>
//JS脚本点击文本框时打开固定大小画面,就是上楼的画面
<script language="javascript" type="text/javascript" >
function room()
{
window.open("../room/roominfoselect.php","_blank", "width=350,height=400,toolbar=no");
}</script>
<table>
<tr>
<td 入宿房號</td>
<td ><input id="txtrid" name="txtrid" type="text" size="15" onclick="room()" /></td>
<td >入宿床號</td>
<td ><input id="txtbid" name="txtbid" type="text" size="15" onclick="room()" /></td>
</tr></table>
比如 :点A页连接到B
A页面:
<script>
a(v){
alert(v);
}
</script>
第二个页面B:
<script>
b(){
window.opener.a('as');//调用父级的 JS 函数
}
</script>
<Td onclick="b();">C</td>
http://download.csdn.net/source/812902
你可以把 window.opener.a(<?php echo i?>);
就可以了
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="javascript" src="./jquery/libs/jquery.js"></script>
<script language="javascript">
jQuery(function($)
{
$('#test').click(function(){
var oMsg = $('#tmsg');
var oDiv = $('#msg');
oDiv.css('zindex', 100);
oDiv.show('slow');
//ajax获取数据
$.ajax({
type: 'post',
url: 'getData.php',
dataType: 'json',
success: function(jsonText){
var length = jsonText.length;
var objTable = document.getElementById('tmsg');
var objTbody = objTable.childNodes[0];
var objTR = objTbody.childNodes[1];
//置空数据
for(var i=objTbody.childNodes.length-1;i>1 ;i--)
{
objTbody.removeChild(objTbody.childNodes[i]);
}
for(var i=0;i<length;i++)
{
var tmpTR = objTR.cloneNode(true);
objTbody.appendChild(tmpTR);
tmpTR.style.display = "";
var tmpID = tmpTR.childNodes[0].innerHTML;
tmpID = tmpID.replace(/{id}/ig,jsonText[i].id);
tmpID = tmpID.replace(/{name}/ig,jsonText[i].name);
tmpID = tmpID.replace(/{card}/ig,jsonText[i].card);
tmpTR.childNodes[0].innerHTML = tmpID;
tmpTR.childNodes[1].innerHTML = jsonText[i].name;
tmpTR.childNodes[2].innerHTML = jsonText[i].card;
}
$('.aTD').each(function(){
$(this).click(function(){
var arrCard = this.id.split("_");
$('#test')[0].value = arrCard[1] + "_" + arrCard[2];
oDiv.hide('slow');
});
});
},//success
error: function(xmlHttp, message, code){
alert(message);
}//error
});//ajax
});
})//jquery
</script>
</head>
<body>
<form action='sendinfo.php' name="user_info" method='post' enctype="multipart/form-data" onsubmit="return saveUserInfo();">
<input type='text' name='test' id='test' value="">
</form>
<div id="msg" style="display:none;position: absolute;background-color:#fff1e1;border:1px black solid;padding: 10px;">
<table border='1' id='tmsg'><tr><td width='100'>id</td><td width='200'>解行卡</td><td width='200'>银行名称</td></tr><tr style='display:none'><td id='id' width='100'><a class='aTD' id='{id}_{name}_{card}' href='javascript:///'>{id}</a></td><td width='200'>{name}</td><td width='200'>{card}</td></tr></table>
</div>
</body>
</html>[code][code=PHP]<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");//从一维数组中生成josn
function __jsonText($array)
{
$str = "{";
foreach($array as $key=> $value)
{
$value = str_replace("\"", "\\\"", $value);
if($str != "{") $str.=",";
$str .= "$key: " . "\"$value\"";
}
$str .= "}"; return $str;
}$arrCard = array(
array('id'=>'1', 'name'=>'中国银行', 'card'=>'中国银行卡'),
array('id'=>'2', 'name'=>'工商银行', 'card'=>'工商银行卡'),
array('id'=>'3', 'name'=>'建设银行', 'card'=>'建设银行卡'),
array('id'=>'4', 'name'=>'农业银行', 'card'=>'农业银行卡'),
);
$strJson = "";
foreach($arrCard as $key=>$value)
{
$strJson .= __jsonText($value) . ",";
}
echo sprintf('[%s]', rtrim($strJson, ','));
?>
然后接着显示下面这个
取值可以这样取
<script language='javascript'>
alert(document.getElementById('test').value);
</script>
document.getElementById("txtbid").value=document.room_form.txtbedno.value;现在改成这样但只取到第一个
document.getElementById("txtrid").value=document.getElementById("txtroomno").value;
document.getElementById("txtbid").value=document.getElementById("txtbedno").value;
因为txtroomno,txtbedno的值是从数据库循环取出来的,name又是一样的,估计还是要用循环取.有问题再请教了!
<script>function roombed(){ for(var i=0;i<=document.getElementById("txtid").length;i++)
{
if(document.getElementById("txtid")[i].checked==true)
{
document.getElementById("txtrid").value=document.getElementById("txtroomno")[i].value;
document.getElementById("txtbid").value=document.getElementById("txtbedno")[i].value;
}
else
{
alert("error error error !");
}
}
}
</script>
//这里的值是从数据库里取出的 <input type="checkbox" id="txtid" name="txtid[]" value="<? echo $row['id']; ?">//复选框
<input id="txtroomno" name="txtroomno[]" type="text" size="15" value="<? echo $row['roomno']; ?>" >
<input id="txtbedno" name="txtbedno[]" type="text" size="15" value="<? echo $row['bedno']; ?>" > <input id="txtrid" name="txtrid" type="text">
<input id="txtbid" name="txtbid" type="text"> <input type="submit" name="oper2" value="確定" onClick="roombed()" >现在就是当我点击确定的时候要把从数据库循环取出的值分别显示在txtrid,txtbid里,并且是先选中了一个复选框,以上JS代码没取到,请教了!