ACMAIN_CHM帮我看下问题.关于上传的。

ChinaXtHuLang 2010-07-08 02:57:45
index.asp页面:
<!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=gb2312" />
<title>无标题文档</title>
<script language="javascript" type="text/javascript">
//插入列表
function addurl(){
var thisurl="地址"+(document.myform.dourl.length+1)+"|http://";
var url=prompt("请输入地址名称和链接,中间用"|"隔开",thisurl);
if(url!=null&&url!=""){
document.myform.dourl.options[document.myform.dourl.length]=new Option(url,url);
}
}
function modifyurl(){
if(document.myform.dourl.length==0){
return false;
}
var thisurl=document.myform.dourl.value;
if(thisurl==""){
alert("请先选择一个地址,再点修改按钮!");
return false;
}
var url=prompt("请输入地址名称和链接,中间用"|"隔开",thisurl);
if(url!=thisurl&&url!=null&&url!=""){
document.myform.dourl.options[document.myform.dourl.selectedIndex]=new Option(url,url);
}
}
function delurl(){
if(document.myform.dourl.length==0){
return false;
}
var thisurl=document.myform.dourl.value;
if(thisurl==""){
alert("请先选择一个地址,再点删除按钮!");
return false;
}
document.myform.dourl.options[document.myform.dourl.selectedIndex]=null;
}
//居中弹出窗体
function getwindow(URL,width,height){
window.open(URL,'','width='+width+',height='+height+',top='+(screen.height-height)/2+',left='+(screen.width-width)/2);
}
</script>
<style type="text/css">
html,body{margin:0;padding:0;height: 100.1%;}
body{font-family:tahoma,arial, helvetica, sans-serif;font-size:12px;color:#666;text-align:left;}
form{margin:0;padding:0;}
button,input,textarea,select{margin-right:5px;border: 1px solid #777;font-size: 12px;}
.checkbox{margin-bottom:-1px;margin-right:0px;border: 0px;}
button,input{padding-top:4px;padding-bottom:2px;}
.bt2{padding:4px 15px 2px;margin:5px;height:20px;font-weight:bold;background:#fff;}
</style>
</head>

<body>
<form action="1.html" method="post" name="myform">
<select name="dourl" id="dourl" size="5" ondblclick="return modifyurl();" multiple style="width:405px;">
</select>
<li>
<input type="button" class="bt2" value="上 传" onClick="getwindow('oUpLoad.asp?oUpLoadType=Pic&FormName=myform&FormInput=dourl',350,60);">
<input type="button" class="bt2" value="添 加" onClick="addurl();">
<input type="button" class="bt2" value="修 改" onClick="return modifyurl();">
<input type="button" class="bt2" value="删 除" onClick="delurl();">
</li>
</form>
</body>
</html>

采用的是弹出窗口的形式上传的。
oUpLoad.asp
页面有段代码是:
Sub UpLoadOpener(FName,FInput,FValue,OutStr)
Echo("<script language=""javascript"" type=""text/javascript"" charset=""gb2312"">")
Echo("var url = '图片说明|" & FValue &"';")
Echo("parent.document."&FName&"."&FInput&".options[parent.document."&FName&"."&FInput&".length]=new Option(url,url);")
Echo("alert('"&OutStr&"');")
Echo("window.opener =null;")
Echo("window.close();")
Echo("</script>")
End Sub

Sub Echo(str)
Response.Write(str) & vbcrlf
End Sub


我的意思是想把最后的结果返回到下拉框里面去:
<select name="dourl" id="dourl" size="5" ondblclick="return modifyurl();" multiple style="width:405px;">
</select>

但是总是返回不进去:
上传之后,oUpLoad.asp页面:
<script language="javascript" type="text/javascript" charset="gb2312"> 
var url = '图片说明|UpLoadFile/Pic/201007081456437416010432.jpg';
parent.document.myform.dourl.options[parent.document.myform.dourl.length]=new Option(url,url);
alert('上传成功!');
window.opener =null;
window.close();
</script>


怎么才可以返回进去啊?
...全文
90 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
ChinaXtHuLang 2010-07-09
  • 打赏
  • 举报
回复
就是有点奇怪。为什么不能直接用
Echo("window.opener.document."&FName&"."&FInput&".options[parent.document."&FName&"."&FInput&".length]=new Option(url,url);")


我原本里面是有
window.opener
ChinaXtHuLang 2010-07-09
  • 打赏
  • 举报
回复
<!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" xml:lang="zh-cn" lang="zh-cn">
<head>
<title>上传文件</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
<meta http-equiv="Expires" content="0">


和这些没有关系。。
ChinaXtHuLang 2010-07-09
  • 打赏
  • 举报
回复
搞定了。我晕死了。。。
  • 打赏
  • 举报
回复
你把parent
改成window.opener
看看
ChinaXtHuLang 2010-07-09
  • 打赏
  • 举报
回复
还是不行。
ChinaXtHuLang 2010-07-09
  • 打赏
  • 举报
回复
上传页面都听你的去掉了。


index.asp页面的要不要去掉?。。
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
这个声明去了吧或者改成<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">这样看看
程序现在是没问题的
  • 打赏
  • 举报
回复
你现在的错误是找不到那个函数,也就是说没起到父子窗口的作用
就是说
错误提示:
parent.upcon is not a function
ChinaXtHuLang 2010-07-09
  • 打赏
  • 举报
回复
听你的也改了。还是一样。。
  • 打赏
  • 举报
回复

<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
<meta http-equiv="Expires" content="0">
删掉

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn">

改为
<html>

试试吧
ChinaXtHuLang 2010-07-09
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 chinmo 的回复:]

刚看了一下,你都没加那个函数
[/Quote]

哪个。能不能说明白点。我index.asp页面的加了。
function upcon(url){
if(url!=null&&url!=""){
document.myform.dourl.options[document.myform.dourl.length]=new Option(url,url);
}
}

上传页面也改了:
Sub UpLoadOpener(FName,FInput,FValue,OutStr)
Echo("<script language=""javascript"" type=""text/javascript"" charset=""gb2312"">")
' Echo("var url = '图片说明|" & FValue &"';")
' Echo("window.opener.document."&FName&"."&FInput&".options[parent.document."&FName&"."&FInput&".length]=new Option(url,url);")
' Echo("alert(parent.document."&FName&"."&FInput&".options[parent.document."&FName&"."&FInput&".options.selectedIndex].value);")
Echo("parent.upcon('"& FValue &"')")
Echo("alert('"&OutStr&"');")
Echo("window.opener =null;")
Echo("window.close();")
Echo("</script>")
End Sub


哪里没有改?
  • 打赏
  • 举报
回复
刚看了一下,你都没加那个函数
  • 打赏
  • 举报
回复
<script>
这样就行了,不要搞那么长
还有用的什么打开的子窗口
ChinaXtHuLang 2010-07-09
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 chinmo 的回复:]

建议你调用父函数比较方便些
就是说把
Echo("parent.document."&FName&"."&FInput&".options[parent.document."&FName&"."&FInput&".length]=new Option(url,url);")
改为
Echo("parent.upcon('"&……
[/Quote]
已经改了。还是不行。。
最后看源代码就这样了:
<script language="javascript" type="text/javascript" charset="gb2312"> 
parent.upcon('UpLoadFile/Pic/201007091111132619054052.jpg')
alert('上传成功!');
window.opener =null;
window.close();
</script>

改后的那个过程:
Sub UpLoadOpener(FName,FInput,FValue,OutStr)
Echo("<script language=""javascript"" type=""text/javascript"" charset=""gb2312"">")
' Echo("var url = '图片说明|" & FValue &"';")
' Echo("window.opener.document."&FName&"."&FInput&".options[parent.document."&FName&"."&FInput&".length]=new Option(url,url);")
' Echo("alert(parent.document."&FName&"."&FInput&".options[parent.document."&FName&"."&FInput&".options.selectedIndex].value);")
Echo("parent.upcon('"& FValue &"')")
Echo("alert('"&OutStr&"');")
Echo("window.opener =null;")
Echo("window.close();")
Echo("</script>")
End Sub
  • 打赏
  • 举报
回复
建议你调用父函数比较方便些
就是说把
Echo("parent.document."&FName&"."&FInput&".options[parent.document."&FName&"."&FInput&".length]=new Option(url,url);")
改为
Echo("parent.upcon('"& url &"')")
这样一个父级函数
然后在
index.asp
加一个
function upcon(url){
if(url!=null&&url!=""){
document.myform.dourl.options[document.myform.dourl.length]=new Option(url,url);
}
}
ChinaXtHuLang 2010-07-09
  • 打赏
  • 举报
回复
加上了。还是不行。。
我的测试地址是:
http://www.woniu720.cn/hulang/UpLoad/
楼上的请你帮忙测试下。。有个上传按钮。。如果没有成功。你查看下弹出上传后的那个页面的源文件吧。。
谢谢。到底如何解决
yangtututu 2010-07-09
  • 打赏
  • 举报
回复
var url = '图片说明|UpLoadFile/Pic/201007081456437416010432.jpg';
parent.document.myform.dourl.options[parent.document.myform.dourl.length]=new Option(url,url);
//增加一句 看去返回框中间的内容是否正常,主要检查 两者之间值的传递是否正常
alert(parent.document.myform.dourl.options[parent.document.myform.dourl.options.selectedIndex].value)

alert('上传成功!');
window.opener =null;
window.close();

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧