注册 登录
编程论坛 ASP技术论坛

怎样设置标题不可为空

电脑小童 发布于 2011-05-08 11:09, 482 次点击
大家好 我写了一段asp代码 作用是提交表单 但是请问大家怎样 设置才能使我的xm 这个不能我空
<%

    Dim strxm ,strlxfs,,strshijian,stryp
   
    strxm = trim(Request.Form("xm"))
    strlxfs= trim(Request.Form("lxfs"))
    stryp= trim(Request.Form("ypsl"))
    strshijian= trim(Request.Form("sjap"))
   
   
    dim rs
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.open "biaodan",conn,1,3
    rs.addnew
    rs("name")=strxm
    rs("lxfs")=strlxfs
    rs("yangpin")=stryp
     rs("shijian")=strshijian
     
    rs.update
    rs.close
    response.Write("<script> alert( '新记录已成功增加! '); </script> ")
   
    %>

是不是要加上if strxm="" then
    Response.write ("<script> alert( '标题不可为空! '); </script> ")
    Response.write ("<script>history.go(-1)</script>")
    response.end
    else
但是我加上后不能正常显示网页 请问大家应该怎么办啊 谢谢大家
2 回复
#2
lxd09802011-05-08 11:18
<%

    Dim strxm ,strlxfs,,strshijian,stryp
   
    strxm = trim(Request.Form("xm"))
    strlxfs= trim(Request.Form("lxfs"))
    stryp= trim(Request.Form("ypsl"))
    strshijian= trim(Request.Form("sjap"))
   
if strxm<>"" then
    dim rs
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.open "biaodan",conn,1,3
    rs.addnew
    rs("name")=strxm
    rs("lxfs")=strlxfs
    rs("yangpin")=stryp
     rs("shijian")=strshijian
     
    rs.update
    rs.close
    response.Write("<script> alert( '新记录已成功增加! '); </script> ")

esle
   Response.write ("<script> alert( '标题不可为空! '); </script> ")
    Response.write ("<script>history.go(-1)</script>")
    response.end

   
    %>
#3
电脑小童2011-05-08 11:33
谢谢你 但是放在我的网页中不能显示 (你的else写错了) 不知道为什么
1