当前位置:   article > 正文

html父窗体传数据,javascript 子窗体父窗体相互传值方法

html给父窗口传数据

脚本之家精简使用版本,一般情况好多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:selAll()">全选

 

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)来执行赋值操作.

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/690582
推荐阅读
相关标签
  

闽ICP备14008679号