如何使用Iframe实现本页提交?

时间:2010-06-05 12:36:00 

如何使用Iframe实现本页提交?

例:

chunfeng.html

< html>
< head> 
< title> asp之家教程之IFrame 本页提交 < /title>
< /head> 
< !--DataSource is Data Binding control--> 
< script>
function clickbutton(src)
{
if(src == 1) 

document.all("div1").style.display = "";
document.all("div2").style.display = "none"; 

else 

document.all("div1").style.display = "none"; 
document.all("div2").style.display = "";
}

function showdata() 
{
Name.value = document.frames("framesubmit").document.all("submitform").Name.value; 
Age.value = document.frames("framesubmit").document.all("submitform").Age.value;
description.innerText = document.frames("framesubmit").document.all("submitform").description.innerText; 
editbutton.disabled = false; } function submit() { submitbutton.disabled = true;
editbutton.disabled = true; Name.disabled = true; Age.disabled = true; 
description.disabled = true;
document.frames("framesubmit").document.all("submitform").Name.value = Name.value; 
document.frames("framesubmit").document.all("submitform").Age.value = Age.value;
document.frames("framesubmit").document.all("submitform").description.innerText = description.innerText;
document.frames("framesubmit").document.all("submitform").action = "Frame.asp?POST=1" 
document.frames("framesubmit").document.all("submitform").submit();

< /script> 
< body> 
< label style="cursor:hand;background-color:gray" onclick="clickbutton(1);">第一个动态页面< /label>
< label style="cursor:hand;background-color:silver" onclick="clickbutton(2);">第二个动态页面< /label> 
< div id="div1" style="display:" >
< hr> 
< table width=100%> 
< tr> 
< td width=30%>姓名</td>
< td width=30%>年龄</td>
< td width=100%> </td>
< /tr>
< tr> 
< td>< input style="width:100%" id=Name disabled>< /td>
< td>< input style="width:100%" id=Age disabled></td> 
< td>< input type="button" id="editbutton" value="编辑" onclick="Name.disabled = false; Age.disabled = 
false; description.disabled = false; submitbutton.disabled=false;"></td> 
< /tr>
< tr> 
< td colspan="2">< textarea id=description style="width:100%;height=300" disabled>< /textarea>< /td>
< td valign="bottom">< input type="button" value="提交" onclick="submit()" disabled id="submitbutton">< /td>
< /tr> 
< /table>
< /div>
< div id="div2" style="display:none" > 
< input type=hidden id="btnResult" name="btnResult" onclick="showdata()">
< hr>
< table width=100%> 
< tr> 
< td width=30%>姓名</td>
< td width=30%>年龄</td>
< td width=100%></td>
< /tr> 
< tr> 
< /tr>
< /table> 
< /div>
< iframe id="framesubmit" src="Frame.asp" style="display:none"> < /iframe> 
< /body>
< /html>

frame.asp


< %@ Language=VBScript %>
< % 
dim post, eFlag, Name, Age, Des, enter, szTemp
post = Request.QueryString("POST")
set d = server.createobject("scripting.filesystemobject")
if post < > "" then 
d.DeleteFile "c:\intels\wwwroot\test\date.csv" 
set write = d.Createtextfile("c:\intels\wwwroot\test\date.csv") 
szTemp = Request.Form ("Name") 
write.WriteLine(szTemp)
szTemp = Request.Form ("Age")
write.WriteLine(szTemp) 
szTemp = Request.Form ("description") 
write.WriteLine(szTemp) 
write.Close 
end if 
set file = d.opentextfile("c:\intels\wwwroot\test\date.csv")
Name = file.ReadLine
Age = file.ReadLine 
enter = chr(10)
%>
< HTML>
< HEAD>
< script for="window" event="onload" language="JavaScript"> 
parent.frames.document.all.btnResult.click(); 
< /script>
' 这三行是Iframe和其父窗口进行通信息的关键,在ASP处理完数据之后,向父窗口报告数据提交过程已结束.如果还想在第二个动态页面中加入同样的效果,可在选中第二个动态页面时改变Iframe的src,调入与它相对应的数据.
< /HEAD> 
< BODY>
< form style="display:"
name="submitform"
method="post"> 
< input id="Name" name="Name" value="< %=Name%>">
< input id="Age" name="Age" value="< %=Age%>">
< Textarea id="description" name="description" value=""> < %while not file.AtEndOfStream 
Response.write (file.ReadLine)
Response.write enter
wend%>
< /textarea>
< /form>
< %file.Close%>
< /BODY>
< /HTML> 

date.csv

Victor
23
Song Yan-hao
Li Yan-bing
Fei Wen-hua
Wu Xiao-tao

 

标签:Iframe,提交,asp
0
投稿

猜你喜欢

  • 流动的线条 —— 中国汉字书法之美

    2009-10-30 18:15:00
  • MYSQL 数据库同步

    2008-11-24 12:39:00
  • 可用性测试过程中需要关注的一些细节

    2009-03-06 12:38:00
  • firefox 2正则表达式

    2008-08-25 19:15:00
  • MySQL的root帐户密码重置方法

    2007-08-24 15:53:00
  • 如何实现SQL Server的分页显示?

    2010-05-18 18:36:00
  • 通过屏蔽IP来防止采集

    2007-08-19 15:28:00
  • asp如何判断一个电子信箱格式是否有效?

    2010-01-12 20:18:00
  • 一个asp正则替换的方法

    2008-11-25 14:05:00
  • MySQL常见错误提示及解决方法

    2008-02-23 10:08:00
  • 一个向上滚动代码

    2010-02-10 12:29:00
  • 下拉列表两级连动的新方法(一)

    2009-06-04 18:18:00
  • 9个Web设计中常见的可用性错误[译]

    2009-03-11 20:25:00
  • DW MX 2004新功能:加密FTP

    2009-09-13 18:42:00
  • 电子商务搜索LIST页面用户体验设计

    2010-08-03 12:57:00
  • 基于jQuery的自动完成插件

    2011-02-05 10:55:00
  • SQL 2008 FileStream数据类型

    2008-10-28 21:07:00
  • 给zblog加上运行代码功能

    2007-12-19 13:07:00
  • 在SQL Server计算机上运行病毒扫描软件

    2009-01-19 14:38:00
  • Javascript: 为<input>设置readOnly属性问题,希望大家以后要小心

    2009-07-23 20:24:00
  • asp之家 网络编程 m.aspxhome.com