首页 新闻 论坛 群组 Blog 文档 下载 读书 Tag 网摘 搜索 .NET Java 游戏 视频 人才 外包 培训 数据库 书店 程序员
中国软件网
欢迎您:游客 | 登录 注册 帮助
  • 表单中按钮单击触发一个过程的问题 [已结贴,结贴人:chjin]
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-04-16 11:43:49 楼主
    部分代码如下:
    <%
    function save
    ........代码部分

    end function
    %>

    <form>
    <input type="button" name="b1" value="保存" onclick="save()">
    </form>


    这样使用是否正确?
    20  修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-04-16 11:48:371楼 得分:20
    不正确
    <%%>是服务器端代码
    onclick="save()"是客户端代码
    两者没有关系
    当onclick出现的时候 <%%>中的代码早就执行完毕了
    要达到目的,只有递交表单或访问url,请求xx.asp,触发 <%%>代码的执行。
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-04-16 11:53:252楼 得分:0
    非常感谢,

    我试了很多次,慢慢有点这种感觉,看来服务器端与客户端还是有很大的不同,初学者很容易搞糊涂.
    这样只能再增加一个页面来处理了吧,

    如果是调用自已来处理,有什么好办法吗?
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-04-16 11:56:133楼 得分:0
    如果做验证应该用javascript
    修改 删除 举报 引用 回复
    进入用户个人空间
    加为好友
    发送私信
    在线聊天
    发表于:2008-04-16 12:13:084楼 得分:0
    想做一个存储数据到数据库的操作,全部代码如下:

    <!--#include file="conn.asp"-->
    <script language="javascript">
    function back()
    {
    location.href="index.asp";
    }
    </script>
    <%
    if request.servervariables("content_length") <>0 then
    response.write"ok"
    end if
    iid=cint(request.querystring("id"))
    set rs=server.createobject("adodb.recordset")
    msql="select * from utable where id="&iid
    rs.open msql,conn,1,3
    if rs.bof and rs.eof then
      response.write "此记录已删除"
      response.write " <input type='button' name='b3' value='返回' onclick='back();'> "
      response.end
    end if
    %>
    <html>
    <head> <title>修改记录 </title> </head>
    <body>
    <form method="post" action="modifydata.asp">
    姓名: <input type="text" name="name" value= <%=rs("name")%>> <br>
    性别: <select name="sex"> <option value="男" <%if rs("sex")="男" then response.write "selected" end if%>>男 </option> <option value="女" <%if rs("sex")="女" then response.write "selected" end if%>>女 </option> </select> <br>
    <!--因为是服务器端脚本,所以向浏览器输入HTML关键字需要使用response.write方法-->
    电话: <input type="text" name="tel" value= <%=rs("tel")%>> <br>
    Q Q : <input type="text" name="qq" value= <%=rs("qq")%>> <br>
    网站: <input type="text" name="web" value= <%=rs("web")%>> <br>
    邮箱: <input type="text" name="email" value= <%=rs("email")%>> <br>
    备注: <input type="text" name="memo" value= <%=rs("memo")%>> <br>
    <input type="submit" name="b1" value="保存">
    <input type="reset" name="b2" value="重改">
    <input type="button" name="b3" value="返回" onclick="back();">
    </form>
    <body>
    </html>

    修改 删除 举报 引用 回复

    网站简介广告服务网站地图帮助联系方式诚聘英才English 问题报告
    世纪乐知(北京)网络技术有限公司 版权所有 京 ICP 证 020026 号
    Copyright © 2000-2007, CSDN.NET, All Rights Reserved