简单的js页面传数据
2009-11-05 10:03
162 查看
js是很强大的,就是因为它的强大至今我都没搞定它。。。
最近小接触了下,用到了页面间的传值,不得不写下,主要怕以后忘了。。。呵呵。。。
页面1:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function LoadSysOption()
{
var URL="/js44.aspx?";//跳到页面2
var popstyle = "DialogWidth:500px; DialogHeight=400px; status:no";
var obj=new Object();
obj.txt=document.getElementById('txtPriv');
window.showModalDialog(URL,obj,popstyle);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtPriv" runat="server"></asp:TextBox>
<input id="Button1" type="button" value="button" onclick="LoadSysOption()"/></div>
</form>
</body>
</html>
页面2:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function add()
{
var text=document.getElementById('TextBox1').value;
var obj=parent.dialogArguments;//这个很关键
obj.txt.value=text;//把TextBox1的值传给页面1中的TextBox
window.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="Button1" type="button" value="button" onclick="add()"/></div>
</form>
</body>
</html>
其实对于这个简单的js原理我也不是很清楚的。。。
最近小接触了下,用到了页面间的传值,不得不写下,主要怕以后忘了。。。呵呵。。。
页面1:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function LoadSysOption()
{
var URL="/js44.aspx?";//跳到页面2
var popstyle = "DialogWidth:500px; DialogHeight=400px; status:no";
var obj=new Object();
obj.txt=document.getElementById('txtPriv');
window.showModalDialog(URL,obj,popstyle);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtPriv" runat="server"></asp:TextBox>
<input id="Button1" type="button" value="button" onclick="LoadSysOption()"/></div>
</form>
</body>
</html>
页面2:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function add()
{
var text=document.getElementById('TextBox1').value;
var obj=parent.dialogArguments;//这个很关键
obj.txt.value=text;//把TextBox1的值传给页面1中的TextBox
window.close();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="Button1" type="button" value="button" onclick="add()"/></div>
</form>
</body>
</html>
其实对于这个简单的js原理我也不是很清楚的。。。
相关文章推荐
- JavaEE day03 使用JS完成简单的数据校验、完成图片轮播效果、完成页面定时弹出广告、完成表单校验
- js获取form表单所有数据的简单方法
- vue.js配合$.post从后台获取数据简单demo分享
- JS把数据库的JSON数据输出渲染到html页面
- js中escape的用法----前端页面简单加密
- 经典js代码 实现动态传值 实现动态页面传值 options动态显示数据
- (4.4.1)使用storyboard实现页面跳转,简单的数据传递
- C#+JS简单实现 定时轮询数据表 以及时弹出消息提示窗口
- node.js学习之用路由方法获取简单的图文html页面
- js数据层中间件单页运用简单构思和应用案例
- 利用js-对象实现简单的动态论坛页面
- 一步一步使用Ext JS MVC与Asp.Net MVC 3开发简单的CMS后台管理系统之数据篇
- 简单的ListView点击某一行 将行中的某些数据传递到下一个页面
- [JS前端开发] js/jquery控制页面动态加载数据 滑动滚动条自动加载事件
- [javascript library]使用js实现页面刷新后依然保留表单填写的数据
- JS 实现简单的页面局部打印
- 【iOS界面处理】使用storyboard实现页面跳转,简单的数据传递
- Vuejs刷新页面子组件数据丢失问题的一点笔记
- angularjs $state.go页面不刷新数据
- 通过JS、JQ,实现对json数据调取,并循环展示到页面