本站精简使用版本,一般情况好多cms都有一些这样的函数。dedecms中的选择相关文章也是用的这样的函数。下面给出具体的代码。
父页面核心代码:
<script><br>function SelectArcListA(fname){ <br>var posLeft = 10; <br>var posTop = 10; <br>window.open("content_select_list.asp?f="+fname+"&k="+form1.keyword.value, "selArcList", "scrollbars=yes,resizable=yes,statebar=no,width=700,height=500,left="+posLeft+", top="+posTop); <br>}<br></script>
子页面的核心代码:
<script language="javascript"> <br>//获得选中文件的文件名 <br>function getCheckboxItem() <br>{ <br>var allSel=""; <br>if(document.form2.arcID.value) return document.form2.arcID.value; <br>for(i=0;i<document.form2.arcID.length;i++) <br>{ <br>if(document.form2.arcID[i].checked) <br>{ <br>if(allSel=="") <br>allSel = document.form2.arcID[i].value; <br>else <br>allSel = allSel+","+document.form2.arcID[i].value; <br>} <br>} <br>return allSel; <br>} <br>function selAll() <br>{ <br>for(i=0;i<document.form2.arcID.length;i++) <br>{ <br>if(!document.form2.arcID[i].checked) <br>{ <br>document.form2.arcID[i].checked=true; <br>} <br>} <br>} <br>function noSelAll() <br>{ <br>for(i=0;i<document.form2.arcID.length;i++) <br>{ <br>if(document.form2.arcID[i].checked) <br>{ <br>document.form2.arcID[i].checked=false; <br>} <br>} <br>} <br>function ReturnValue() <br>{ <br>if(window.opener.document.form1.xiangguanid.value==""){ <br>window.opener.document.form1.xiangguanid.value = getCheckboxItem(); <br>} <br>else{ <br>window.opener.document.form1.xiangguanid.value += ","+getCheckboxItem(); <br>} <br>alert("成功增加你选中的ID,你可以继续增加"); <br>//window.opener=true; <br>//window.close(); <br>}<br></script>
下面是html代码,页面中需要">输出选择的id
href="javascript:selAll()">全选 href="javascript:noSelAll()">取消 href="javascript:ReturnValue()">把选定值加到列表
一下是补充:
//模式窗体传值
<script language="javascript" type="text/javascript"> <br>function doInput() <br>{ <br>var win = window.showModalDialog("Childform.html",window,"dialogWidth=500px;dialogHeight=300px;center=yes;status=no"); <br>if(win != null) <br>{ <br>document.getElementById("parentTextBox").value = win; <br>} <br>} <br></script>
在新弹出的窗体里输入数据,传输到父窗体.
点这里弹出子窗体
立即学习“Java免费学习笔记(深入)”;
点这里返回
<script language="javascript" type="text/javascript"> <br>document.getElementById("childTextBox").value = window.dialogArguments.document.getElementById("parentTextBox").value; <br>function doPassToParent() <br>{ <br>if(document.getElementById("childTextBox").value.length <=0) <br>{ <br>alert("请填写数据"); <br>return; <br>} <br>window.returnValue = document.getElementById("childTextBox").value; <br>window.close(); <br><br>} <br></script>
//子窗体和父窗体传值
1.新建两个页面 一个是 Parent.html
<script language="javascript" type="text/javascript"> <br>function OpenWindow(){ <br>window.open('son.html'); <br>} <br>function setValue(m_strValue){ <br>document.getElementById("txt_Value").value = m_strValue; <br>} <br></script>
另一个是子窗体 :
<script language="javascript" type="text/javascript"> <br>function CloseWind(){ <br>opener.setValue("传值到父窗体"); <br>window.close(); <br>} <br></script>
2.通过子窗体执行的父窗体的setValue(m_strValue)来执行赋值操作.











