donglin6659 2014-03-18 12:52
浏览 207

使用Handsontable Spreadsheet将数据从jQuery表发布到PHP

I want to Post data's from a handsontable ([][1]) spreadsheet for get them on PHP with $_REQUEST.

My page is intended to allow the input of information and then to validate them by a button. I tried for a <form> $ a. Ajax or $. Post but I wasn't able to do what I wanted.

Here is my code :

<script src=""></script>
 <script data-jsfiddle='common' src='add/jquery.handsontable.full.js'></script>
 <link data-jsfiddle='common' rel='stylesheet' media='screen' href='add/jquery.handsontable.full.css'>
 <script data-jsfiddle='common' src='add/jquery.handsontable.removeRow.js'></script>
 <script data-jsfiddle='common' src='add/'></script>
 <link data-jsfiddle='common' rel='stylesheet' media='screen' href='add/jquery.handsontable.removeRow.css'>
 <!-- the below is only needed for DateCell (uses jQuery UI Datepicker) -->
 <script data-jsfiddle='common' src='add/jquery-ui.custom.min.js'></script>
 <link data-jsfiddle='common' rel='stylesheet' media='screen' href='add/jquery-ui.custom.css'>

<script type="text/javascript">
 $("#spreadsheet").submit( function () {    
    alert(data);// alert the data from the server
   return false;   

    <div id="container">
      <div class="columnLayout">

     <div class="rowLayout">
       <div class="descLayout">
      <div class="pad" data-jsfiddle="tablecompt">

        <div id="tablecompt"></div>

       <div class="codeLayout">
      <div class="pad">
      <FORM NAME='spreadsheet' class='formulaire' ID='spreadsheet' METHOD='POST'>

         <style data-jsfiddle="common">
        .handsontable .currentRow {
          background-color: #E7E8EF;

        .handsontable .currentCol {
          background-color: #F9F9FB;
         <script data-jsfiddle="tablecompt">

        var container = $("#tablecompt");

        var people = [
          {ctopextract: false}

        var email_validator_fn = function (value, callback) {
         if (/.+@.+/.test(value)) {
         else {
          }, 1000);

          columnSorting: true,
          manualColumnResize: true,
          manualColumnMove: true,
          currentRowClassName: 'currentRow',
          currentColClassName: 'currentCol',
          removeRowPlugin: true,
          rowHeaders: true,
          data: people,
          minSpareRows: 10,
          fixedRowsTop: 1,
          contextMenu: true,
          beforeChange: function (changes, source) {
          afterChange: function (changes, source) {
         if (source !== 'loadData') {
          colHeaders: ['Société', 'TETAB', 'TNUMINT', 'TDOCU', 'CTOPEXTRACT', 'Date comptable', 'Journal', 'Tiers', 'Compte', 'Libellé', 'Débit (€)', 'Crédit (€)', 'Nature', 'TCI', 'TCI1', 'TCI2', 'TCI3', 'TCI4'],
          columns: [
         {data: 'societe'},
         {data: 'tetab'},
         {data: 'tnumint', type: 'numeric'},
         {data: 'tdocu'},
         {data: 'ctopextract', type: 'checkbox'},
         {data: 'date', type: 'date'},
         {data: 'tjournal', type: 'dropdown', source: ["8A", "8B", "8E", "8F", "8M"]},
         {data: 'ttiers'},
         {data: 'tcptg'},
         {data: 'tlibecr'},
         {data: 'debit', type: 'numeric', format: '0,0.00 $', language: 'de-de'},
         {data: 'credit', type: 'numeric', format: '0,0.00 $', language: 'de-de'},
         {data: 'nature'},
         {data: 'tci'},
         {data: 'tci1'},
         {data: 'tci2'},
         {data: 'tci3'},
         {data: 'tci4'}
        <button class='formulaire' type='submit' class='action' NAME='action' id="action" VALUE='M'>Mise à jour</button>
        <button class='formulaire' onClick=\"javascript:document.location.href='index.php'\" />Annuler</button>

Could you help me with sending my jQuery spreadsheet from a button to my PHP page (which is the same page).

I'm new in this domain and I haven't been able to find this information. I found examples for Ajax but that doesn't interest me.

Thank you in advance for your help.

-- Sweet

  • 写回答

1条回答 默认 最新

  • dro80463 2014-03-20 13:08

    I finally found the solution. Using a form is not necessary. Here is the code:

    var handsontable = $'handsontable');
    $parent.find('button[name=save]').click(function () {
            url: "link.php",
            data: {"data": handsontable.getData()}, //returns all cells' data
            type: 'POST',
            success: function (data) {
            error: function () {
                $console.text('Erreur de sauvegarde.');
    本回答被题主选为最佳回答 , 对您是否有帮助呢?



    • ¥20 C语言字符串不区分大小写字典排序相关问题
    • ¥15 关于#python#的问题:我希望通过逆向技术爬取1688搜索页下滑加载的数据
    • ¥15 学习C++过程中遇到的问题
    • ¥15 关于Linux的终端里,模拟实现一个带口令保护的屏保程序遇到的输入输出的问题!(语言-c语言)
    • ¥15 学习C++过程中遇到的问题
    • ¥15 请问,这个嵌入式Linux系统怎么分析,crc检验区域在哪
    • ¥15 二分类改为多分类问题
    • ¥15 Unity微信小游戏上调用ReadPixels()方法报错
    • ¥15 如何通过求后验分布求得样本中属于两种物种其中一种的概率?
    • ¥15 q从常量变成sin函数,怎么改写python代码?