如何做这个函数判断?

pdysuny 2004-04-23 10:12:11
我有两个地方都通过函数editSubmit(selid,Type)来提交,但我想在a处执行这样的操作<a href="javascript:editSubmit(<%=scset.GetFieldValue("id")%>,1);"> 提交</a>.
在b处执行这样的操作<a href="javascript:editSubmit(<%=scset.GetFieldValue("id")%>,0);"> 提交</a>.

函数如下:
function editSubmit(selid,Type) {
if (document.Goods.GoodsNo.value=="") {
alert("请填写物品编号");
document.Goods.GoodsNo.focus();
return;
}
if (document.Goods.GoodsName.value=="") {
alert("请填写物品名称!");
document.Goods.GoodsName.focus();
return;
}
//我要editSubmit(selid,Type)中type=1时执行下面这个操作
if (!document.Goods.SalesPrice.value.match(/^\d+$/)) {
alert("售价不能为空或只能为数字!");
document.Goods.SalesPrice.focus();
return;
}

document.Goods.editID.value=selid;
document.Goods.GoodsType.value=Type;
document.Goods.act.value="editSubmit";
document.Goods.action="GoodsManage.asp";
document.Goods.submit();
return;
}

也就是editSubmit(selid,Type) 中 type=1或0时的判断,该如何做啊?

...全文
48 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
pdysuny 2004-04-23
  • 打赏
  • 举报
回复
再帮我看看,错在哪里了?
function editSubmit(selid,Type) {
if (Type==1){
if (document.Goods.GoodsNo.value=="") {
alert("请填写物品编号");
document.Goods.GoodsNo.focus();
return;
}
if (document.Goods.GoodsName.value=="") {
alert("请填写物品名称!");
document.Goods.GoodsName.focus();
return;
}

if (!document.Goods.SalesPrice.value.match(/^\d+$/){
alert("售价不能为空或只能为数字!");
document.Goods.SalesPrice.focus();
return;
}
document.Goods.editID.value=selid;
document.Goods.GoodsType.value=Type;
document.Goods.act.value="editSubmit";
document.Goods.action="GoodsManage.asp";
document.Goods.submit();
return;

}

else if (Type==0){
if (document.Goods.GoodsNo.value=="") {
alert("请填写物品编号");
document.Goods.GoodsNo.focus();
return;
}
if (document.Goods.GoodsName.value=="") {
alert("请填写物品名称!");
document.Goods.GoodsName.focus();
return;
}
document.Goods.editID.value=selid;
document.Goods.GoodsType.value=Type;
document.Goods.act.value="editSubmit";
document.Goods.action="GoodsManage.asp";
document.Goods.submit();
return;
}

}
pdysuny 2004-04-23
  • 打赏
  • 举报
回复
不要看我信誉分少,就不回答啊,今天绝对结帖,上次发广告才被扣的。
pdysuny 2004-04-23
  • 打赏
  • 举报
回复
这样为何有错啊?
function editSubmit(selid,Type) {
if (Type==1){
if (document.Goods.GoodsNo.value=="") {
alert("请填写物品编号");
document.Goods.GoodsNo.focus();
return;
}
if (document.Goods.GoodsName.value=="") {
alert("请填写物品名称!");
document.Goods.GoodsName.focus();
return;
}


if (!document.Goods.SalesPrice.value.match(/^\d+$/){
alert("售价不能为空或只能为数字!");
document.Goods.SalesPrice.focus();
return;
}
document.Goods.editID.value=selid;
document.Goods.GoodsType.value=Type;
document.Goods.act.value="editSubmit";
document.Goods.action="GoodsManage.asp";
document.Goods.submit();
return;
}
}else{
if (document.Goods.GoodsNo.value=="") {
alert("请填写物品编号");
document.Goods.GoodsNo.focus();
return;
}
if (document.Goods.GoodsName.value=="") {
alert("请填写物品名称!");
document.Goods.GoodsName.focus();
return;
}

document.Goods.editID.value=selid;
document.Goods.GoodsType.value=Type;
document.Goods.act.value="editSubmit";
document.Goods.action="GoodsManage.asp";
document.Goods.submit();
return;

}
end if
}
vjlin 2004-04-23
  • 打赏
  • 举报
回复
function editSubmit(selid,Type) {
if (document.Goods.GoodsNo.value=="") {
alert("请填写物品编号");
document.Goods.GoodsNo.focus();
return;
}
if (document.Goods.GoodsName.value=="") {
alert("请填写物品名称!");
document.Goods.GoodsName.focus();
return;
}
//我要editSubmit(selid,Type)中type=1时执行下面这个操作
if ((!document.Goods.SalesPrice.value.match(/^\d+$/)) && (Type==1)) {
alert("售价不能为空或只能为数字!");
document.Goods.SalesPrice.focus();
return;
}

document.Goods.editID.value=selid;
document.Goods.GoodsType.value=Type;
document.Goods.act.value="editSubmit";
document.Goods.action="GoodsManage.asp";
document.Goods.submit();
return;
}
vjlin 2004-04-23
  • 打赏
  • 举报
回复
function editSubmit(selid,Type) {
if (Type==1){
if (document.Goods.GoodsNo.value=="") {
alert("请填写物品编号");
document.Goods.GoodsNo.focus();
return;
}
if (document.Goods.GoodsName.value=="") {
alert("请填写物品名称!");
document.Goods.GoodsName.focus();
return;
}
}else{
//我要editSubmit(selid,Type)中type=1时执行下面这个操作
if (!document.Goods.SalesPrice.value.match(/^\d+$/)) {
alert("售价不能为空或只能为数字!");
document.Goods.SalesPrice.focus();
return;
}
}
document.Goods.editID.value=selid;
document.Goods.GoodsType.value=Type;
document.Goods.act.value="editSubmit";
document.Goods.action="GoodsManage.asp";
document.Goods.submit();
return;
}

28,391

社区成员

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

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