双击文本框弹出对话框问题

handy_wzh 2009-07-02 09:14:52
我想实现如下功能:

双击文本框A,弹出一个新的对话框B或一个页面(带确定与取消按钮),里面可以输入条件查询数据库中的多个数据,根据这些数据选择所需要的后,按对话框B或页面中的“确定”按钮后,就会把我选中的数据自动加载到最初的那个页面中,并自动关闭对话框B或页面.

就是要实现这个功能,不知道谁做过类似的功能,最好有详细代码,谢谢!!!
...全文
256 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
凡夫与俗子 2009-07-03
  • 打赏
  • 举报
回复
另外借你的贴,谢谢sd5816690。
凡夫与俗子 2009-07-03
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 handy_wzh 的回复:]
模式b.html 的数据能不能从数据库里查询而得呢,我做了个查询,但查询后的数据是打开一个新的窗口,且在新的窗口选择的值提交后提示说:dialogArguments.setValue(cb)为空或不是对象.
[/Quote]
楼主问题解决没?你在b.html中<head></head>加入<base target="_self">解决新窗口打开问题,如果不是代码问题,那么后面的提示为空或不是对象也能解决。要是还没解决,可以联系我,我们共同探讨。呵呵,我是新手,还请指教
sd5816690 2009-07-02
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 zxdldh007 的回复:]
楼主,你解决了吗?我的解决了,但是我的value是ID值,我想用隐藏域来获取他,而text则获取id值对应的名称,不知道该怎么写啊。。
<input type="text" name="pi_pid" id="pi_pid" value="这里获取ID的值" readonly />
<input type="text" name="pi_pid" id="pi_pid" value="这里获取对应的商品名称" readonly>
第二个value怎么获取。
[/Quote]
用自定义属性
<input type="checkbox" name="ids" value="1" producename="商品名称" />
ids[i].getAttribute("producename");
凡夫与俗子 2009-07-02
  • 打赏
  • 举报
回复
楼主,你解决了吗?我的解决了,但是我的value是ID值,我想用隐藏域来获取他,而text则获取id值对应的名称,不知道该怎么写啊。。
<input type="text" name="pi_pid" id="pi_pid" value="这里获取ID的值" readonly />
<input type="text" name="pi_pid" id="pi_pid" value="这里获取对应的商品名称" readonly>
第二个value怎么获取。
凡夫与俗子 2009-07-02
  • 打赏
  • 举报
回复
哇靠,这不正是我要的东西吗!刚想进来发帖子就看到楼主这个。。。哈。我和楼主差不多意思,双击弹出可查询的页面,页面内容是从数据库里获得的,选择后返回值填到表单里,提交后存入另外一个数据表。
sd5816690 2009-07-02
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 handy_wzh 的回复:]
实现双击后,弹出一个对话框,在对话框内查询数据,然后选择某一个查询结果,把值传回到14.asp页面的文本框中.
请问如何编码,谢谢,在线等.
[/Quote]
意思是双击哪一个TD,选择后,就在对应的 text 里显示被选择的值?
handy_wzh 2009-07-02
  • 打赏
  • 举报
回复
SD5816690你的方法很好,但是我所要的更复杂些,比如:这两个文件

文件1:14.asp
<table>
<tr>
<td ondblclick="preSelect()">双击选择</td>
<td><input type="text" id="text1" value="显示数据1" /></td>
</tr>
<tr>
<td ondblclick="preSelect()"> </td>
<td><input name="textfield" type="text" id="textfield" value="显示数据2"></td>
</tr>
<tr>
<td ondblclick="preSelect()"> </td>
<td><input name="textfield2" type="text" id="textfield2" value="显示数据3"></td>
</tr>
</table>


文件2:15.asp
<table width="338" border="0">
<tr>
<td width="158" nowrap>条件:
<input name="Test" type="text" id="text1" size="15" /></td>
<td width="164" nowrap><input type="button" value="搜索" onClick="ok()" /></td>
</tr>
</table>
<table>
<tr>
<td width="16">1</td>
<td width="85">数据11</td>
<td width="67">数据12</td>
<td width="99">数据13</td>
<td width="49"><input type="checkbox" name="ids" value="1" /></td>
</tr>
<tr>
<td>2</td>
<td>数据21</td>
<td>数据22</td>
<td>数据23</td>
<td><input type="checkbox" name="ids" value="2" /></td>
</tr>
<tr>
<td>3</td>
<td>数据31</td>
<td>数据32</td>
<td>数据33</td>
<td><input type="checkbox" name="ids" value="3" /></td>
</tr>
<tr>
<td>4</td>
<td>数据41</td>
<td>数据42</td>
<td>数据43</td>
<td><input type="checkbox" name="ids" value="4" /></td>
</tr>
</table>
<input type="button" value="确定" onclick="ok()" />
<input type="button" value="取消" onclick="window.close()" />


实现双击后,弹出一个对话框,在对话框内查询数据,然后选择某一个查询结果,把值传回到14.asp页面的文本框中.
请问如何编码,谢谢,在线等.
sd5816690 2009-07-02
  • 打赏
  • 举报
回复
模式a.html

<table>
<tr>
<td ondblclick="preSelect()">双击选择</td>
<td><input type="text" id="text1" value="这里显示被选择的ID" /></td>
</tr>
</table>
<script>
function preSelect(){
showModalDialog("模式b.html", window, "");
}

function setValue(value){
document.getElementById("text1").value = value;
}
</script>

模式b.html

<table>
<tr>
<td>1</td>
<td>第1条数据</td>
<td><input type="checkbox" name="ids" value="1" /></td>
</tr>
<tr>
<td>2</td>
<td>第2条数据</td>
<td><input type="checkbox" name="ids" value="2" /></td>
</tr>
<tr>
<td>3</td>
<td>第3条数据</td>
<td><input type="checkbox" name="ids" value="3" /></td>
</tr>
<tr>
<td>4</td>
<td>第4条数据</td>
<td><input type="checkbox" name="ids" value="4" /></td>
</tr>
<tr>
<td>5</td>
<td>第5条数据</td>
<td><input type="checkbox" name="ids" value="5" /></td>
</tr>
</table>
<input type="button" value="确定" onclick="ok()" />
<input type="button" value="取消" onclick="window.close()" />
<script>
function ok(){
var checkedValue = "";
var ids = document.getElementsByName("ids");
for(var i = 0; i < ids.length; i++){
if(ids[i].checked){
checkedValue += ids[i].value + ",";
}
}
checkedValue = checkedValue.replace(/,$/, "");
window.dialogArguments.setValue(checkedValue);
window.close();
}
</script>
明珠佩佩 2009-07-02
  • 打赏
  • 举报
回复

<table>
<tr>
<td>
<input type=text name="test" ondblclick="OpenWindow('test.asp','test page');">
</td>
</tr>
</table>
<script language="JavaScript">
function OpenWindow(url,windowname)
{
window.open(url,windowname,'left=150,top=100,height=300,width=400,toolbar=no,menubar=no,scrollbars=no')
}
</script>
BlueSky4014 2009-07-02
  • 打赏
  • 举报
回复
学习了
sd5816690 2009-07-02
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 handy_wzh 的回复:]
模式b.html 的数据能不能从数据库里查询而得呢,我做了个查询,但查询后的数据是打开一个新的窗口,且在新的窗口选择的值提交后提示说:dialogArguments.setValue(cb)为空或不是对象.
[/Quote]
当然可以,11楼不是写出来了吗?
只要按照 15 楼的格式生成 checkbox 就行了
handy_wzh 2009-07-02
  • 打赏
  • 举报
回复
<!--#include file="Js/Conn.asp" -->
<form name="form1" method="post" action="模式b.html
">
<TABLE width=322 height=30 border=0 cellpadding=0 cellspacing=0 class=zi>
<TR>
<TD width=12% align=right nowrap>测试:</TD>
<TD width=51% nowrap>
<input name=Test type=text id=Test size=6></TD>
<TD width=37% nowrap>
<input type=submit name=Submit value=搜索 /></TD>
</TR>
</TABLE>
</form>
<%
Set rs=Server.CreateObject("ADODB.RecordSet")
if request.Form("Test")<>"" then
Test1=request.Form("Test")
' Test2=request.Form("Asset_ID")
sql="select * from Standard where Use_ID='"&Test1&"'"

rs.Open sql,conn,1,3
%>
<table width="400">
<%
dim sum
sum=0
do while not rs.eof
sum=sum+1
%>
<tr>
<td width="23"><%=sum%></td>
<td width="338"><%=rs("Asset_Name")%>---<%=rs("Asset_ID")%>---<%=rs("Asset_Brand")%>
</td>
<td width="23">
<input type="checkbox" name="ids" productid="1" productname="<%=rs("Asset_Name")%>" code="<%=rs("Asset_ID")%>" brand="<%=rs("Asset_Brand")%>" /></td>
</tr>
<%
rs.movenext
loop
rs.close
%>
</table>
<input type="button" value="确定" onclick="ok()" />
<input type="button" value="取消" onclick="window.close()" />

<% else
response.Write("请先查询数据")
end if
%>
<script>
function ok(){
textid = document.URL.replace(/textid=([^&]*)/, "$1");

var cb = null;
var ids = document.getElementsByName("ids");
for(var i = 0; i < ids.length; i++){
if(ids[i].checked){
cb = ids[i];
}
}
window.dialogArguments.setValue(cb);
window.close();
}
</script>


比如说模式b.html 文件能不能像上面这样查询后再选择提交?
为什么查询后会跳出新窗口而不是在本页显示?
handy_wzh 2009-07-02
  • 打赏
  • 举报
回复
模式b.html 的数据能不能从数据库里查询而得呢,我做了个查询,但查询后的数据是打开一个新的窗口,且在新的窗口选择的值提交后提示说:dialogArguments.setValue(cb)为空或不是对象.
sd5816690 2009-07-02
  • 打赏
  • 举报
回复
模式a.html

<table>
<tr>
<td ondblclick="preSelect('text1')">双击选择</td>
<td><input type="text" id="text1" value="" /></td>
<td><input type="text" id="text2" value="" /></td>
</tr>
<tr>
<td></td>
<td><input type="text" id="text3" value="" /></td>
<td><input type="text" id="text4" value="" /></td>
</tr>
</table>
<script>
function preSelect(){
showModalDialog("模式b.html", window, "");
}

function setValue(cb){
document.getElementById("text1").value = cb.getAttribute("productid");
document.getElementById("text2").value = cb.getAttribute("productname");
document.getElementById("text3").value = cb.getAttribute("code");
document.getElementById("text4").value = cb.getAttribute("brand");
}
</script>

模式b.html

<table>
<tr>
<td>1</td>
<td>第1条数据</td>
<td><input type="checkbox" name="ids" productid="1" productname="产品1号" code="11" brand="品牌1" /></td>
</tr>
<tr>
<tr>
<td>2</td>
<td>第2条数据</td>
<td><input type="checkbox" name="ids" productid="2" productname="产品2号" code="22" brand="品牌2" /></td>
</tr>
<tr>
<tr>
<td>3</td>
<td>第3条数据</td>
<td><input type="checkbox" name="ids" productid="3" productname="产品3号" code="33" brand="品牌3" /></td>
</tr>
<tr>
<tr>
<td>4</td>
<td>第4条数据</td>
<td><input type="checkbox" name="ids" productid="4" productname="产品4号" code="44" brand="品牌4" /></td>
</tr>
<tr>
<tr>
<td>5</td>
<td>第5条数据</td>
<td><input type="checkbox" name="ids" productid="5" productname="产品5号" code="55" brand="品牌5" /></td>
</tr>
<tr>
</table>
<input type="button" value="确定" onclick="ok()" />
<input type="button" value="取消" onclick="window.close()" />
<script>
function ok(){
textid = document.URL.replace(/textid=([^&]*)/, "$1");

var cb = null;
var ids = document.getElementsByName("ids");
for(var i = 0; i < ids.length; i++){
if(ids[i].checked){
cb = ids[i];
}
}
window.dialogArguments.setValue(cb);
window.close();
}
</script>
凡夫与俗子 2009-07-02
  • 打赏
  • 举报
回复
是啊,我也想知道具体点的。。我是新手
handy_wzh 2009-07-02
  • 打赏
  • 举报
回复
楼上的能不能具体点呢,或许给个例子参考参考?
sd5816690 2009-07-02
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 handy_wzh 的回复:]
举个例子:在15.asp页面查询到结果,如下
序号 名称 编号 品牌 选择
1 注塑机 MSP010030 NESSEI 选择框
2 注塑机 MSP010087 NESSEI 选择框
3 机械手 MSP020049 STAR 选择框
4 机械手 MSP020083 STAR 选择框
5 温控箱 MSP130004 麦士德 选择框

如果我要选择序号1的数据返回到14.asp页面中,并对应地填到各自的文本框中,又咋弄啊.
[/Quote]
10 楼代码中只有一个 textid
可以改用数组,然后在 15.asp 的 ok 方法中,也传递数组作为参数(取参数时,参照8楼的自定义属性)
handy_wzh 2009-07-02
  • 打赏
  • 举报
回复
文件:14.asp
<table width="400" border="1">
<tr>
<td width="61"> </td>
<td colspan="3">双击此处选择</td>
</tr>
<tr>
<td>写入日期:</td>
<td width="143">
<input type="text" name="aa" id="aa" value="<%=date()%>"></td>
<td width="69">名称: </td>
<td width="99"><input type="text" name="textfield" id="textfield"></td>
</tr>
<tr>
<td>编号:</td>
<td><input type="text" name="textfield2" id="textfield2"></td>
<td>品牌:</td>
<td><input type="text" name="textfield3" id="textfield3"></td>
</tr>
<tr>
<td colspan="4" align="center"><input type="submit" name="button" id="button" value="保存">
   
<input type="button" name="button2" id="button2" value="取消"></td>
</tr>
</table>


文件:15.asp
<!--#include file="Js/Conn.asp" -->
<form name="form1" method="post" action="15.asp">
<TABLE width=322 height=30 border=0 cellpadding=0 cellspacing=0 class=zi>
<TR>
<TD width=12% align=right nowrap>测试:</TD>
<TD width=51% nowrap>
<input name=Test type=text id=Test size=6></TD>
<TD width=37% nowrap>
<input type=submit name=Submit value=搜索 /></TD>
</TR>
</TABLE>
</form>
<%
Set rs=Server.CreateObject("ADODB.RecordSet")
if request.Form("Test")<>"" then
Test1=request.Form("Test")
' Test2=request.Form("Asset_ID")
sql="select * from Standard where Use_ID='"&Test1&"'"

rs.Open sql,conn,1,3
%>
<table border="1">
<tr>
<td>序号</td>
<td>名称</td>
<td>编号</td>
<td>品牌</td>
<td>选择</td>
</tr>
<%
dim sum
sum=0
do while not rs.eof
sum=sum+1
%>
<tr>
<td width="16"><%=sum%></td>
<td width="85"><%=rs("Asset_Name")%></td>
<td width="67"><%=rs("Asset_ID")%></td>
<td width="99"><%=rs("Asset_Brand")%></td>
<td width="49"><input type="checkbox" name="checkbox" id="checkbox" /></td>
</tr>
<%
rs.movenext
loop
rs.close
%>
</table>
<input type="button" value="确定" onclick="ok()" />
<input type="button" value="取消" onclick="window.close()" />

<% else
response.Write("请先查询数据")
end if
%>


举个例子:在15.asp页面查询到结果,如下
序号 名称 编号 品牌 选择
1 注塑机 MSP010030 NESSEI 选择框
2 注塑机 MSP010087 NESSEI 选择框
3 机械手 MSP020049 STAR 选择框
4 机械手 MSP020083 STAR 选择框
5 温控箱 MSP130004 麦士德 选择框

如果我要选择序号1的数据返回到14.asp页面中,并对应地填到各自的文本框中,又咋弄啊.
sd5816690 2009-07-02
  • 打赏
  • 举报
回复
3楼代码中 模式b.html 不用改
模式a.html 如下:

<table>
<tr>
<td ondblclick="preSelect('text1')">双击选择</td>
<td><input type="text" id="text1" value="这里显示被选择的ID" /></td>
</tr>
<tr>
<td ondblclick="preSelect('text2')">双击选择</td>
<td><input type="text" id="text2" value="这里显示被选择的ID" /></td>
</tr>
</table>
<script>
var textid = null;
function preSelect(newtextid){
textid = newtextid;
showModalDialog("模式b.html", window, "");
}

function setValue(value){
document.getElementById(textid).value = value;
}
</script>
handy_wzh 2009-07-02
  • 打赏
  • 举报
回复
sd5816690,差不多是你说的意思,请问咋弄呢?

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧