父窗口提交子窗口(iframe)数据

父窗口(list.jsp)
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet"
	href="<%=basePath%>manage/themes/default/style/uistyle.css" />
<link rel="stylesheet"
	href="<%=basePath%>manage/themes/default/style/jquery-ui.css" />
<link rel="stylesheet"
	href="<%=basePath%>manage/themes/default/date/skin/WdatePicker.css" />
<script type="text/javascript"
	src="<%=basePath%>manage/themes/default/script/jquery.js"></script>
<script type="text/javascript"
	src="<%=basePath%>manage/themes/default/script/jquery-ui.js"></script>
<script type="text/javascript"
	src="<%=basePath%>manage/themes/default/script/uiscript.js"></script>
<script type="text/javascript"
	src="<%=basePath%>manage/themes/date/WdatePicker.js"></script>
<script type="text/javascript"
	src="<%=basePath%>manage/themes/date/lang/zh-cn.js"></script>

<script type="text/javascript">
	$(function() {
		// Dialog
		$('#addlivewindow').dialog({
			autoOpen : false,
			width : 600,
			buttons : {
				"Ok" : function() {
					
					$(this).find("#iframepage").contents().find("form").submit();
					$(this).dialog("close");
					
				},
				"Cancel" : function() {
					$(this).dialog("close");
				}
			}
		});
		
		
		// Dialog Link
		$('#addlive_link').click(function() {
			$('#addlivewindow').dialog('open');
			$("#iframepage").attr("src","gotoAddChannel");
			return false;
		});
		$('#addlive_link, ul#icons li').hover(function() {
			$(this).addClass('ui-state-hover');
		}, function() {
			$(this).removeClass('ui-state-hover');
		});
	});
	
	function testChannel(){
	var sid=$("#serverId").val();
		if(sid==-1){
			alert('选择服务器.');
			return false;
		}
		
		var url='<%=basePath%>manage/video/server/channel/testChannel';
		$.post(url,{serverId:sid,channelName:$("input[id=sourceChannel]").val()},function(data){
			if(typeof data.state ==='string'){
				if(data.state=='error'){
					alert(data.message);
					$("input[name=checkState]").val(-1);
				}else{
					alert(data.message);
					$("input[name=checkState]").val(1);
				}
			}
		},'json');
	}
	
	function changeAD() {
		if(document.getElementById("autoFlag").checked) {
			$("#playAD").attr("disabled",false);
			 $("#bufferAD").attr("disabled","");
		}else {
			$("#playAD").attr("disabled","");
			 $("#bufferAD").attr("disabled",false);
		}
	}
	
</script>

</head>

<body id="concentbox">
	<div id="concent" style="height: 900px;">
		<div class="concent_title">
			<ul>
				<li><a class="nomala" href="#">首页</a></li>
				<li>&gt;</li>
				<li><a class="nomala" href="#">媒资</a></li>
				<li>&gt;</li>
				<li><a class="nomala" href="#">服务器</a></li>
				<li>&gt;</li>
				<li><a class="nomala">频道发布点</a></li>
			</ul>
		</div>
		<!--mlist-->
		<div class="mlist">
			<div class="mlist_title">
				<h3>节目单</h3>
			</div>
				<select name='action'>
					<option value='-1' selected='selected'>批量操作</option>
					<option value='edit'>编辑</option>
					<option value='trash'>删除</option>
				</select> <input type="button" value="提交" />
				<input type="button" name="add" id="addlive_link"
					value="添加频道" />
				<table class="mlist_table" border="0" cellpadding="0"
					cellspacing="0">
					<tr class="mlist_table_title">
						<td><input class="checkall" type="checkbox" name="checkbox" />
							发布点名称</td>
						<td>服务器</td>
						<td>开启/关闭</td>
						<td>操作人</td>
						<td>操作</td>
					</tr>
					<s:iterator id="chlist" value="chlist" status="status">
						<tr class="mlist_table_con">
							<td>
								<input type="checkbox" /> ${channelName}
							</td>
							<td>${channelServer.serverName }</td>
							<td>启动状态:<s:if test="channelState==0">停止</s:if>
								<s:else>启动</s:else>&nbsp;&nbsp;<a class="nomala"
								href="startOrStopChannel?channelId=${channelId }">关闭</a>
							 </td>
							<td>${operator }</td>
							<td><ul class="mlist_table_conul">
									<li><a class="main_icons theedit" title="编辑" href="editChannel.action?channelId=${channelId }"></a></li>
									<li><a class="main_icons thedel" title="删除" href="deleteChannel.action?channelId=${channelId }"></a></li>
								</ul></td>
						</tr>
					</s:iterator>

				</table>
			<div class="mlist_pages">
			<form action="channelList" method="get" id="pageListForm" name="pageListForm">
				${pagerContext }
			</form></div>
			</div>
			<div class="clear"></div>
		</div>
		<!--mlist end-->

	
	<div id="addlivewindow" title="添加直播频道">
	<input type="hidden" id="checkState" name="checkState" value="0"/>
		<iframe id="iframepage" width="100%" height="300px" frameborder="0"></iframe>
	</div>
</body>
</html>





子窗口(add.jsp)
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet"
	href="<%=basePath%>manage/themes/default/style/uistyle.css" />
<link rel="stylesheet"
	href="<%=basePath%>manage/themes/default/style/jquery-ui.css" />
<link rel="stylesheet"
	href="<%=basePath%>manage/themes/default/date/skin/WdatePicker.css" />
<script type="text/javascript"
	src="<%=basePath%>manage/themes/default/script/jquery.js"></script>
<script type="text/javascript"
	src="<%=basePath%>manage/themes/default/script/jquery-ui.js"></script>
<script type="text/javascript"
	src="<%=basePath%>manage/themes/default/script/uiscript.js"></script>
<script type="text/javascript"
	src="<%=basePath%>manage/themes/date/WdatePicker.js"></script>
<script type="text/javascript"
	src="<%=basePath%>manage/themes/date/lang/zh-cn.js"></script>
<script type="text/javascript">
	function selectChange() {
		if(document.getElementById("autoFlag").checked) {
			document.getElementById("ndiv").style.display='none';
			document.getElementById("cdiv").style.display='block';
		}else {
			document.getElementById("cdiv").style.display='none';
			document.getElementById("ndiv").style.display='block';
		}
	}
	
	function testChannel(){
		var sid=$("#ser_Id").val();
			if(sid==-1){
				alert('选择服务器.');
				return false;
			}
			
			var url='<%=basePath%>manage/video/server/channel/testChannel';
			$.post(url,{ser_Id:sid,channelName:$("input[id=sourceChannel]").val()},function(data){
				if(typeof data.state ==='string'){
					if(data.state=='error'){
						alert(data.message);
						$("input[name=checkState]").val(-1);
					}else{
						alert(data.message);
						$("input[name=checkState]").val(1);
					}
				}
			},'json');
		}
</script>
</head>
<body>
		<input type="hidden" id="checkState" name="checkState" value="0"/>
		<form action="addChannel" method="post" name="form"  enctype="multipart/form-data">
				<input type="hidden" value="${serverId }" id="serverId" name="serverId" />
				<label for="channel_name">频道名称:</label>
				<input id="channel_name" name="channel.channelAnotherName" type="text" class="middletext" /> 
				<input id="autoFlag" type="checkbox" onclick="selectChange()"/>关联已有发布点<br/>
				选择服务器:<select id="ser_Id" name="ser_Id">
							<option value="-1">--请选择服务器--</option>
							<s:iterator value="servers" status="status">
								<option value="${serverId }">${serverName }</option>
							</s:iterator>
						</select>
				<div style="display: none;" id="cdiv">选择发布点:<select name="ch_Id">
							<option value="-1">--请选择频道--</option>
						</select></div><br />
				<div id="ndiv">
					<label for="sourceChannel">发布点名称:</label>
					<input id="sourceChannel" name="channel.channelName" type="text" class="middletext" style="width: 300px;"/> &nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="testChannel()" style="color:green">检测</a><br/>
					<label for="rwmc">授权文件路径:</label>
					<input type="file" id="file" name="channelFile" />
				</div>
			</form>
</body>
</html>


效果图(add.jsp)

你可能感兴趣的:(iframe)