<% String s1= request.getParameter("filter");%>
<html>
<head>
<script type="text/javascript">
var imageURL = "redar.jpg";
function changeImage(img_id)
{
var imgs=document.getElementsByTagName('img');
for(var i=1;i<=imgs.length;i++) {
var imgid="myImage"+i;
if(imgid==img_id){
document.getElementById(img_id).src="greenar.gif";
}
else{
document.getElementById(imgid).src=imageURL;
}
}
}
function trim(stringToTrim) {
return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function validate()
{
var emp_value ="";
var count=0;
var imgs=document.getElementsByTagName('img');
for(var i=1;i<=imgs.length;i++)
{ var imgid="myImage"+i;
var imgurl = document.getElementById(imgid).src;
var imgar = imgurl.split("/");
if(imgar[4]=="greenar.gif")
{
count++;
}
}
if(count==0)
{
alert("Please Select Employee Id");
return false;
}
return true;
}
function showEmp()
{ if(validate())
{
var imgs=document.getElementsByTagName('img');
for(var i=1;i<=imgs.length;i++) {
var imgid="myImage"+i;
var emp_id = "eid"+i;
var imgurl = document.getElementById(imgid).src;
var imgar = imgurl.split("/");
if(imgar[4]=="greenar.gif"){
var emp_value = document.getElementById(emp_id).value;
}
}
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null){
alert ("Browser does not support HTTP Request")
return
}
var url="getPatient.jsp"
url=url+"?emp_id="+emp_value;
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
}
function stateChanged()
{ if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ var showdata = xmlHttp.responseText;
var strar = showdata.split(":");
if(strar.length>0)
{
var strname = strar[1];
window.opener.location.reload();
window.location.reload();
window.close();
opener.document.getElementById("puid").value=strar[1];
opener.document.getElementById("fname").value=strar[2];
opener.document.getElementById("prdate").value=strar[3];
window.close();
}
}
}
function GetXmlHttpObject()
{ var xmlHttp=null;
try
{ // Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{ //Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</script>
</head>
<body>
<form name="employee">
<br><br>
<table border="1" width="300px" align="center" bgcolor="#CDFFFF">
<tr><td align="center" colspan=3><b>Select Patient</b></td></tr>
<% System.out.println(s1);
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";
String dbName = "gold";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";
int sumcount = 0;
Statement st;
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url + dbName, userName, password);
String query = "select * from gold.newdailyupdate where pmobileno='" + s1 + "' ";
st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
int count = 0;
while (rs.next()) {
count++;
%>
<tr>
<td><input type="hidden" value="<%=rs.getString(20)%>" id="eid<%=count%>"></td>
<td align="right">
<img src="redar.jpg" width="25px" height="25px" name="myImage" onclick="changeImage(this.id);" id="myImage<%=count%>" border="0"></td>
<td><%=rs.getString(3)%></td>
<td width="50%"><%=rs.getString(20)%></td>
</tr>
<%
}
%>
<% } catch (Exception e) {
e.printStackTrace();
}
%>
<tr><td align="center" Colspan=3><input type="button" value="Select" onclick="javascript:showEmp();"></td></tr>
</table>
</form>
</body>
</html>
这是我的弹出窗口页面,我可以在弹出窗口中选择值,这些值必须填充到父窗口字段。 我无法将值存储在父窗口字段中,但“未定义”值存储在父窗口的所有字段中,我无法找到错误。