doukundong9652 2016-01-13 10:27
浏览 1055
已采纳

jQuery如何将数据放入HTML(.data)

Hi all i have a question, I have a web page with a datatable filled with data from my DB. I have a columns of checkbox and a button. When i click on my button, I open a new page that generate an invoice. I have done a script in jQuery which get the ID of my order with the checkbox.

Code of my check box ( i use bootstrap):

 <td><div class="ckbox ckbox-success">
         <input type="checkbox" class="select-invoice" data-idcommande="<?= $commande->getId()?>"/>
         <label for="checkboxSuccess"></label>
     </div>
  </td>

This is the code of my button (bootsrap too):

 <a class="btn btn-labeled btn-warning" href="facture-facture_groupee.html" id="invoicebtn"> <span class="btn-label"><i class="fa fa-eur"></i></span>Facturer les commandes sélectionnées </a>

Now this is the script i've made when i click on my button:

$( "#invoicebtn" ).click(function() {
   $('.select-invoice').each(function() {
       $(this).data("idcommande");             
   }); 
});

This work fine (I have tested with alert())

But now i want to put the id I've collected in the other page but i don't know how to do it.

Thanks for reading and sorry for my english i'm french.

  • 写回答

2条回答 默认 最新

  • dongpinyao2203 2016-01-13 10:41
    关注

    Use Ajax to communicate between client and server.

    Client :

    $.post( "test.php", { name: "John", time: "2pm" } );
    

    Server :

    if($_POST) {
        $name = $_POST['name'];
        $time = $_POST['time'];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退