赞
踩
脚本之家精简使用版本,一般情况好多cms都有一些这样的函数。dedecms中的选择相关文章也是用的这样的函数。下面给出具体的代码。
父页面核心代码:
function SelectArcListA(fname){
var posLeft = 10;
var posTop = 10;
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);
}
子页面的核心代码:
//获得选中文件的文件名
function getCheckboxItem()
{
var allSel="";
if(document.form2.arcID.value) return document.form2.arcID.value;
for(i=0;i
{
if(document.form2.arcID[i].checked)
{
if(allSel=="")
allSel = document.form2.arcID[i].value;
else
allSel = allSel+","+document.form2.arcID[i].value;
}
}
return allSel;
}
function selAll()
{
for(i=0;i
{
if(!document.form2.arcID[i].checked)
{
document.form2.arcID[i].checked=true;
}
}
}
function noSelAll()
{
for(i=0;i
{
if(document.form2.arcID[i].checked)
{
document.form2.arcID[i].checked=false;
}
}
}
function ReturnValue()
{
if(window.opener.document.form1.xiangguanid.value==""){
window.opener.document.form1.xiangguanid.value = getCheckboxItem();
}
else{
window.opener.document.form1.xiangguanid.value += ","+getCheckboxItem();
}
alert("成功增加你选中的ID,你可以继续增加");
//window.opener=true;
//window.close();
}
下面是html代码,页面中需要">输出选择的id
href="javascript:noSelAll()">取消
href="javascript:ReturnValue()">把选定值加到列表
一下是补充:
//模式窗体传值
弹出窗口内录入数据确定后返回给父窗体--主窗体function doInput()
{
var win = window.showModalDialog("Childform.html",window,"dialogWidth=500px;dialogHeight=300px;center=yes;status=no");
if(win != null)
{
document.getElementById("parentTextBox").value = win;
}
}
点这里弹出子窗体
弹出窗口内录入数据确定后返回给父窗体--子窗体点这里返回
document.getElementById("childTextBox").value = window.dialogArguments.document.getElementById("parentTextBox").value;
function doPassToParent()
{
if(document.getElementById("childTextBox").value.length <=0)
{
alert("请填写数据");
return;
}
window.returnValue = document.getElementById("childTextBox").value;
window.close();
}
//子窗体和父窗体传值
1.新建两个页面 一个是 Parent.html
父窗体function OpenWindow(){
window.open('son.html');
}
function setValue(m_strValue){
document.getElementById("txt_Value").value = m_strValue;
}
另一个是子窗体 :
子窗体function CloseWind(){
opener.setValue("传值到父窗体");
window.close();
}
关闭
/>
2.通过子窗体执行的父窗体的setValue(m_strValue)来执行赋值操作.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。