• eval()用法 vb的数据以字符串传递给JS,如何处理(1)


    index.asp
    ----------------------------------------------------------
    <script src="ajax.js></script>

       <form>
    </ul>
       <li>Q Q:<input type="text" maxlength="10" id="qq"  /></li>
                    <li>性别:<input type="radio" name="sex" value="BOY" checked="checked"/>男<input type="radio" name="sex" value="GIRL"/>女<input type="radio" name="sex" value="NONE"/>保密</li>
                    <li>留言:<textarea id="content" cols="60" rows="10"></textarea></li>
               
                    <input type="button" onclick="sendJS();" value="保存" class="button" id="submit" />
                </ul>
                </form>
    ----------------------------------------------------------以上提交用sendJS()处理
    ajax.js

        function sendJS(){
      
            xmlHttp = XMLHttpRequest();
            var qq,sex,content,url;
            qq = getVal("qq");
            sex = getVal("sex");
            content = getVal("content");
            url="";
           
            if(xmlHttp){
                url ="save.asp?qq="+escape(qq)+"&sex="+escape(sex)+"&content="+escape(content);
               
                xmlHttp.open("get",url,true);
               
                xmlHttp.onreadystatechange = function(){
                    if(xmlHttp.readystate==4){
                   
                        if(xmlHttp.status==200){
                            if(xmlHttp.responseText=="1"){
                                alert("添加成功!");
                            }else if(xmlHttp.responseText=="0"){
                                alert("填写完整!")
                            }//1
                        }else{
                            alert("网络错误");
                        }//200
                        addMessage();
                    }//4
               
                };//xmlhttp.onready
                xmlHttp.send(null);
            }//if xmlhttp
        }//fun 


        function XMLHttpRequest(){
            try {
              xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
              try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
              } catch (e2) {
                xmlHttp = false;
              }
            }
            if (!xmlHttp && typeof XMLHttp != 'undefined')
         xmlHttp = new XMLHttpRequest();
            return xmlHttp;
        }
       

    数据的处理交给了save.asp
    ----------------------------------------------------------

    <!--#include file="conn.asp"-->

    <%
    dim qq,sex,content
    qq = request.QueryString("qq")
    sex = request.QueryString("sex")
    content = request.QueryString("content")
    response.Write(content)
    dim rs
    set rs = server.createobject("adodb.recordset")
    rs.Open "book",conn,3,3
    if  qq="" or content="" then
        Response.Write("0")
    else
        rs.AddNew
        rs("qq")=qq
        rs("sex")=sex
        rs("content")=content
        rs.Update
        rs.Close
        set rs=nothing
        Response.Write("1")
    end if
    %>

    以上是保存到数据库,看下篇的读取数据库


  • 相关阅读:
    linux 安装Python3
    MYSQL 字符集设置(终端的字符集)
    Linux LVM Logical Volume Management 逻辑卷的管理
    oracle 重命名和重定位数据文件(Oracle Renaming and Relocating Datafiles)
    Azkaban编译
    基于hive的transform实现自定义分隔符数据导出
    MapReduce优化设置
    hive.groupby.skewindata环境变量与负载均衡
    hive的基本操作
    Shell 数组的定义和使用
  • 原文地址:https://www.cnblogs.com/8586/p/1235362.html
Copyright © 2020-2023  润新知