这一段代码百思不得其解?大侠帮忙看看

sailor001 2003-04-22 09:55:27
如果没有把onSubmit="return isok()"去掉,在后台接收时,description表单值为空。去掉后能正常接受到这个表单的内容。但不能在前台验证其是否为空。到底是为什么?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>上传照片</title>
<link href="style.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
function isok(){
document.photo_file.submit.disabled=true;
if(document.photo_file.photo_file.value==""){
document.photo_file.submit.disabled=false;
alert("难道你不想上传照片吗?");
return false;
}
if(document.photo_file.description.value==""){
document.photo_file.submit.disabled=false;
alert("别忘了给照片一些说明哦!");
return false;
}
return true;
}
</script>
</head>

<body>

<table width="296" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="296" height="30" class="top2" align="center" valign="middle">上传照片</td>
</tr>
<tr>
<td height="16"> </td>
</tr>
<tr>
<td height="135" valign="top"><form action="r_photo.asp" method="post" enctype="multipart/form-data" name="photo_file" onSubmit="return isok()">
照片:
<input type="file" name="photo_file">
<br>
类型:
<select name="type" id="type">
<option value="个人照片">个人照片</option>
<option value="校园风景">校园风景</option>
<option value="其他杂项">其他杂项</option>
</select>
<br>
介绍:<br>
<textarea name="description" cols="40" rows="5" id="description"></textarea>
<br>
<div align="center"><input type="submit" name="Submit" id="submit" value="OK!上传我的照片"></div>
<br>
</form></td>
</tr>
</table>
</body>
</html>
...全文
70 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sailor001 2003-04-22
  • 打赏
  • 举报
回复
这个我知道,如果我去掉那段javascript代码。就不会有接受不到的现象。
kenshin_z 2003-04-22
  • 打赏
  • 举报
回复
你后台接受的方式是不一样的!是以数据流的方式接受的!
PowerHorse 2003-04-22
  • 打赏
  • 举报
回复
应该是你的 ASP 的问题,我用 Perl 接收试验没有问题。
sailor001 2003-04-22
  • 打赏
  • 举报
回复
打个还是不行
使用的是稻香老农制作无组件上传代码,后台没问题,如果去掉那段javascript就可以完全接收数据。现在如果加了那段代码 <textarea name="description" cols="40" rows="5" id="description"></textarea>的值在后台变为空。而 <select name="type" id="type">
<option value="个人照片">个人照片</option>
<option value="校园风景">校园风景</option>
<option value="其他杂项">其他杂项</option>
</select>却正常
接收数据的代码如下
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="upload.inc"-->
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="refresh" content="3;URL=photo.asp">
<title>文件上传</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
dim upload,file,sql,photoType,FilePath
set upload=new upload_5xsoft
set file=upload.file("photo_file")
if file.fileSize>0 then
file.saveAs Server.mappath("uploadphoto/"&file.FileName)
response.write "<br>上传文件:"&file.FileName&" => OK!"
response.write "<br>文件大小:"&file.FileSize
FilePath="./uploadphoto/"&file.FileName
photoType=upload.form("type")
descr=upload.form("description")
response.Write(descr&photoType) ’这边输出的只有photoType,而desc却没有输出
set file=nothing
end if
set upload=nothing

sql="select * from [photo]"
rs.open sql,conn,1,3
rs.addnew
rs("userID")=session("id")
rs("name")=session("name")
rs("photo")=FilePath
rs("type")=photoType
rs("description")=descr ‘这边的代码在添加数据库时却没于报错
rs("date")=now()
rs.update
close_db
%>
</body>
</html>
zhanghk 2003-04-22
  • 打赏
  • 举报
回复
function isok(){
var SubmitButton = document.getElementById("submit");
SubmitButton.disabled=true;
if(document.photo_file.photo_file.value==""){
SubmitButton.disabled=false;
alert("难道你不想上传照片吗?");
return false;
}
if(document.photo_file.description.value==""){
SubmitButton.disabled=false;
alert("别忘了给照片一些说明哦!");
return false;
}
return true;
}
你想当“李逍遥”式的“大侠”吗? 这里无需计算机基础,无需编程经验,你也不必是计算机专业的在校大学生....只要爱好游戏,怀揣梦想! 有一定自主学习能力,跟着刘老师从“编程小白”修炼为游戏研发“大虾”吧!!!学习好Unity,其先决条件是一定要有稳固、扎实的编程基础!课程 《C# For Unity系列之入门篇》配套学习资料链接:http://pan.baidu.com/s/1gflxreN 密码:sou5;刘老师讲Unity学员群(2) 497429806一、热更新系列(技术含量:中高级):A:《lua热更新技术中级篇》https://edu.csdn.net/course/detail/27087B:《热更新框架设计之Xlua基础视频课程》https://edu.csdn.net/course/detail/27110C:《热更新框架设计之热更流程与热补丁技术》https://edu.csdn.net/course/detail/27118D:《热更新框架设计之客户端热更框架(上)》https://edu.csdn.net/course/detail/27132E:《热更新框架设计之客户端热更框架(中)》https://edu.csdn.net/course/detail/27135F:《热更新框架设计之客户端热更框架(下)》https://edu.csdn.net/course/detail/27136二:框架设计系列(技术含量:中级): A:《游戏UI界面框架设计系列视频课程》https://edu.csdn.net/course/detail/27142B:《Unity客户端框架设计PureMVC篇视频课程(上)》https://edu.csdn.net/course/detail/27172C:《Unity客户端框架设计PureMVC篇视频课程(下)》https://edu.csdn.net/course/detail/27173D:《AssetBundle框架设计_框架篇视频课程》https://edu.csdn.net/course/detail/27169三、Unity脚本从入门到精通(技术含量:初级)A:《C# For Unity系列之入门篇》https://edu.csdn.net/course/detail/4560B:《C# For Unity系列之基础篇》https://edu.csdn.net/course/detail/4595C: 《C# For Unity系列之中级篇》https://edu.csdn.net/course/detail/24422D:《C# For Unity系列之进阶篇》https://edu.csdn.net/course/detail/24465四、虚拟现实(VR)与增强现实(AR):(技术含量:初级)A:《虚拟现实之汽车仿真模拟系统 》https://edu.csdn.net/course/detail/26618五、Unity基础课程系列(技术含量:初级) A:《台球游戏与FlappyBirds—Unity快速入门系列视频课程(第1部)》 https://edu.csdn.net/course/detail/24643B:《太空射击与移动端发布技术-Unity快速入门系列视频课程(第2部)》https://edu.csdn.net/course/detail/24645 C:《Unity ECS(二) 小试牛刀》https://edu.csdn.net/course/detail/27096六、Unity ARPG课程(技术含量:初中级):A:《MMOARPG地下守护神_单机版实战视频课程(上部)》https://edu.csdn.net/course/detail/24965B:《MMOARPG地下守护神_单机版实战视频课程(中部)》https://edu.csdn.net/course/detail/24968C:《MMOARPG地下守护神_单机版实战视频课程(下部)》https://edu.csdn.net/course/detail/24979

87,902

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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