zoukankan      html  css  js  c++  java
  • jQueryget函数应用 Joyce

    利用jQuery的get函数通过input标签元素的id将用户填写内容提交到另一个php页面,并进行数据库访问操作

    Page1——subsystem.init.php,用户界面

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
    <title>集中式空调系统在线能效检测及诊断平台-初始化</title>
    <link href="http://www.cnblogs.com/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" /> 
    <script src="http://www.cnblogs.com/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="http://www.cnblogs.com/lib/ligerUI/js/ligerui.min.js"  type="text/javascript"></script>
    <script type="text/javascript">
    $(function ()
    {    
        $("#btn_sure").click(function(){
                $.get(  'user.insert.php',
                        {
                            bsy_id :$("#bsy_id").val(),
                            name :$("#name").val(),        
                        },
                        function(data,textStatus){
                            if(data.length==61){ //插入成功
                                    $.ligerDialog.success(data);
                                }
                            else{
                                    $.ligerDialog.error(data);
                                }
                            });
            });
    });
    </script>
    <style type="text/css">
    #showbox h2{margin:5px auto;text-align:center;background-color:#D6E7FC;border:2px solid #BED5F3;90%;}
    #showbox h2:hover{background-color:#EEF5FD;}
    #info_show{margin:0 auto;85%;} 
    #info_show table {background-color:#F5F5F5;margin:5px 0 5px 30px;border:2px solid #D9E8FB;}
    #info_show table tr td{padding:5px 10px 5px 10px;}
    #btn_sure{100px;height:30px;}
    #btn_reset{100px;height:30px;}
    .line{margin:20px auto;height:2px;background-color:#EBEBEB;}
    </style>
    </head>
    <body>                                                                                                                                                                                                                                                                                                                   
    <div id="showbox">
        <h2>子系统信息——初始化</h2>
        <div id="info_show">
        <form>
        <h3>请填写相关信息:</h3>
                <table>
                    <tr>
                        <td>子系统编号: </td>
                        <td><input type='text' id='bsy_id'></input></td>
                        <td>   </td>
                        <td>子系统名称: </td>
                        <td><input type='text' id='name'></input></td>
                    </tr>                        
                    <tr>
                        <td> </td>
                        <td> </td>
                        <td> </td>
                        <td><input type="button" id="btn_sure" value="提交" class="l-button" ></input></td>
                        <td><input type="reset" id="btn_reset" value="重置" class="l-button" ></input></td>
                    </tr>
                    </table>                            
                </form>
            <div class="line"></div>    
        </div>     
    </div>
    </body>
    </html>

    Page2——subsystem.insert.php,数据库访问操作

    <?php
    /*************************************************************
     * 当插入操作成功时,执行  echo '操作成功!已添加一条新的数据!'
     * 当插入操作失败时,执行 echo '操作失败!'
     * 其他echo 语句不允许出现
     * */
    $_bsy_id=_toString($_GET['bsy_id']); $_name=_toString($_GET['name']);
    _connect(); //连接数据库
    $query ="insert into room_info values($_bsy_id,$_name)"; if(mysql_query($query)) echo '操作成功!已添加一条新的数据!'; else echo '操作失败!'; _close(); ?>

    注:有部分格式相关页面引用未表现出来;另有函数(如_connect())定义在项目其他页面,这里不再说明。

  • 相关阅读:
    apache solr简单搭建
    Flash学习初总结
    UWP多设备加载不同xaml布局文件
    鼠标右键多余选项删除
    用命令查看win10/win8.1等详细激活信息方法:
    win10 登陆选项 无法打开
    UWP应用开发:添加复制按钮,添加引用
    notepad++详细介绍!
    Python安装出现2503 2502 问题解决!
    Genymotion插件安装教程
  • 原文地址:https://www.cnblogs.com/joycelee/p/2778238.html
Copyright © 2011-2022 走看看