JS中Location使用

來源:互聯網
上載者:User

標籤:close   submit   php   資料   https   tab   地址   blog   gif   

JS和CSS ,HTML 與PHP之間的一些體會

    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資料),在後台比較常用到這個

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

 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提交過來的資料要小心點就好了

JS中Location使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.