JS中Location使用

JS和CSS ,HTML 与PHP之间的一些体会javascript

    public function del(){
        $o_id=isset($_REQUEST['o_id'])?$_REQUEST['o_id']:'';
        $ids = isset($_REQUEST['ids'])?$_REQUEST['ids']:'';
        $model = SF('\\model\\AdminModel');
        if(!empty($o_id)){
            if( $model->del('bk_order','o_id='.$o_id)){
                $this->jump('删除成功', 'p=admin&m=Book&a=showList&page', 1);
            }else{
                $this->jump('删除失败', 'p=admin&m=Book&a=showList&page', 1);
            }
        }
        elseif (!empty($ids)){
            $ids =implode(',',$ids);//多选择变成字符串出来
            if($model->del('bk_order','o_id in ('.$ids.')')){
            $this->jump('删除成功', 'p=admin&m=Book&a=showList&page', 1);
             }else{
                $this->jump('删除失败', 'p=admin&m=Book&a=showList&page', 1);
            }
        }

    }
View Code

 

在HTML页面上提交信息到服务器,有数据的话尽可能使用POST 方式,加密,传输量比get大   ,而在接收时就在有post和get就尽可能使用request (可接收cookie数据),在后台比较经常使用到这个php

location.href=全地址 如  https://www.baidu.com/index.php? &word=%20locationhtml

 1 <HTML>
 2 header("content-type:text/html;charset=utf-8");
 3 <body>
 4 <form method="post" action="地址">
 5       <ul class="search">
 6         <li>
 7           <button type="button" name="check"  id="checkall" value=""> 全选/反选</button>
 8           <button type="submit" id="che" onclick="return DelSelect()"> 批量删除</button>
 9         </li>
10       </ul>
11     </div>
12     <table class=" text-center">
13       <tr>
14         <th>序号</th>
15         <th>订单ID</th>
16         <th>用户ID</th>
17         <th>姓名</th>       
18         <th>电话</th>
19         <th>操做</th>
20       </tr>
21       {foreach from=$rows item='row' key='k' name='f1'}
22         <tr>
23            <td> {$smarty.foreach.f1.iteration}</td>
24           <td><input type="checkbox" value="{$row['o_id']}" name="ids[]" />
25           {$row['o_id']}</td>
26           <td>{$row['u_id']}</td>
27           <td>{$row['u_name']}</td>
28           <td>{$row['phone']}</td>
29           <td>{$row['o_intro']}</td>
30           <td>{$row['risetime']|date_format:'%Y-%m-%d %H-%M'}</td>
31           <td><div class="button-group"> <a class="button border-red" href="javascript:void(0)" onclick="return del({$row['o_id']})"> 删除</a> </div></td>
32         </tr>
33       {/foreach}
34 
35 </table>
36   </div>
37   <ul style="margin: 10px 30% 0 30%">{$strpage}</ul>//设定你的页面格式
38 </form>
39 //JS的处理方式为
40 <script type="text/javascript">
41     function del($o_id){
42         if(confirm("您肯定要删除吗?")){
43             location.href="http://www.xxx,com?p=admin&m=Book&a=del&o_id={$row['o_id']}";//location.href链接到你要提交的地方,不过地址要写全,主要是带上你要处理的数据一块儿
44         }
45     }
46       <!--正反选-->
47     $("#checkall").click(function(){
48         $("input[name='ids[]']").each(function(){
49             if (this.checked) {
50                 this.checked = false;
51             } else {
52                 this.checked = true;
53             }
54         });
55     })
56 
57     function DelSelect() {
58         var Checkbox = false;
59         $("input[name='ids[]']").each(function () {
60             if (this.checked == true) {
61                 Checkbox = true;
62             }
63         });
64         if (Checkbox) {
65             var t = confirm("您确认要删除选中的内容吗?");
66             if (t == false) {
67                 location.href = "{%%$url}?p=admin&m=Book&a=del&ids[]={%%$row['o_id']}";
68             }
69         }
70         else {
71             alert("请选择您要删除的内容!");
72             return false;
73         }
74     }
75 </script>
76 </body></html>
View Code
提交过来的数据要当心点就行了