js子页面向父页面传值

本文介绍了如何在JavaScript中实现从子页面向其父页面传递值的方法,包括父页面定义接收函数以及子页面调用该函数进行数据传输的详细步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

父页面方法:

active_freight = {
reload: function () {
table.reload('editReload', {});
},
addData: function (data) {
if(data == null || data.length == 0 || !data instanceof Array){
return false;
}
for(var i = 0; i<data.length; i++){
var has = false;
if(rowsData.length >= 0){
for (var j = 0; j<rowsData.length; j++) {
if(rowsData[j].couponId === data[i].couponId){
has = true;
}
}
}
if(!has){
rowsData.push(data[i]);
}
}
table.reload('editReload', {
url: '',
data: rowsData
});
return true;
}
};

 

子页面方法:

$("#add").on("click", function () {
var param = {};
var couponIds = [];
var checkedData = [];
var checkStatus = table.checkStatus('searchReload');
if (checkStatus.data.length > 0) {
for (var i = 0; i < checkStatus.data.length; i++) {
couponIds.push(checkStatus.data[i].id);
checkedData.push({
"pid": uuid(),
"registeredMarketingId": pageId,
"couponId": checkStatus.data[i].id,
"name": checkStatus.data[i].name,
"minTotalThreshold": checkStatus.data[i].minTotalThreshold,
"subtractAmount": checkStatus.data[i].subtractAmount,
"dischargeRate": checkStatus.data[i].dischargeRate,
"maxDischargeRate": checkStatus.data[i].maxDischargeRate,
"description": checkStatus.data[i].description,
"couponQty": 0,
"couponType":checkStatus.data[i].couponType,
"canAward":'1',
//"effectiveStartTime":checkStatus.data[i].effectiveStartTime,
//"effectiveEndTime":checkStatus.data[i].effectiveEndTime,
"winningRate":0
});
}
var res = parent.active_freight.addData(checkedData);
if(res){
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
parent.layer.close(index);
}
}
if (checkStatus.data.length == 0) {
layer.msg('请最少选择一条数据', {icon: 5});
return;
}
});

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值