日期:2014-05-16  浏览次数:20379 次

js对象的定义以及在弹出窗口中的返回值应用
弹出窗口及返回值的js代码
	function searchFieldPage(){
		var fieldResult = window.showModalDialog('<%=basePath%>bdmField/searchFieldPageForDmn.action?random='+Math.random(),'','dialogWidth=450px;dialogHeight=500px;status:no;resizable=yes;Minimize=yes;Maximize=yes');
		if(fieldResult!=undefined){
			document.getElementById("bdmDmnFieldCnName").value = fieldResult[0].fieldId;
			document.getElementById("bdmDmnFieldId").value = fieldResult[0].fieldName;
			document.getElementById("bdmDmnFieldCnName").value = fieldResult[0].fieldCnName;

			document.getElementById("bdmDmn.odsDmnName").value = fieldResult[0].fieldName;
			document.getElementById("bdmDmn.odsCdDmnName").value = fieldResult[0].fieldName+"_NAME";
			document.getElementById("bdmDmn.edwDmnName").value = fieldResult[0].fieldCnName;
			document.getElementById("bdmDmn.edwCdDmnName").value = fieldResult[0].fieldName+"_NAME";
			
		}
	}

弹出窗口的返回值对象定义及值积累
<script type="text/javascript">
	function selectFieldInfo(){
		var fieldIds = document.getElementsByName("fieldIds");
		var fieldNames = document.getElementsByName("fieldNames");
		var fieldCnNames = document.getElementsByName("fieldCnNames");
		var fieldInfoList = new Array();
		var fieldInfoIndex = 0;
		if(fieldIds!=undefined){
			var fieldId,fieldName,fieldCnName;
			for(var i=0;i<fieldIds.length;i++){
				if(fieldIds[i].checked){//选中的单选按钮
					fieldId = fieldIds[i].value;
					fieldName = fieldNames[i].value;
					fieldCnName = fieldCnNames[i].value;
					var fieldInfo = new FieldInfo(fieldId,fieldName,fieldCnName);
					fieldInfoList[fieldInfoIndex] = fieldInfo;
					fieldInfoIndex++;
				}
			}
		}
		if(fieldInfoIndex==0){
			alert("请选中一个维度!");
			return;
		}
		window.returnValue = fieldInfoList;
		window.close();
	}

	function FieldInfo(fieldId,fieldName,fieldCnName){
		this.fieldId = fieldId;
	    this.fieldName = fieldName;
	    this.fieldCnName = fieldCnName;
	}
</script>