<?php
echo "<table id='example-table' class='table table-bordered table table-hover'>";
echo "<thead><tr class='main-head'>";
echo "<th>S.N.</th>";
echo "<th>Acode</th>";
echo "<th>Aname</th>";
echo "<th>{$lyp_1}</th>";
echo "<th>{$lyp_2}</th>";
echo"<th>Suply</th>";
echo "<th>Sum</th>";
echo "<th>Amount</th>";
echo "</tr></thead>";
$classcode = 'C' . $count;
//$idcode = $nt[0];
//$classcode = 'C' . $idcounter;
//$classamt = 'A' . $idcounter;
$count=1;
while ($row = mysql_fetch_array($res_final)) {
if($row[5]== 's') {
$row4_info = "";
if (($row[4]== 'y')&& ($row[5]!= 's')) {
$row4_info = "<input type='text' id='{$row[0]}' class='A{$count}' value=''>";
}
$row5_info = "";
if ($row[5]== 's') {
$row5_info = "<input type='text' id='{$row[0]}' class='A{$count}' value='' disabled='disabled'>";
}
echo "<tr> <td>". $sn = $startpoint + $count . "</td>
<td class='C{$count}'>" .$row[0] ."</td>
<td >" . $row[1] . "</td>
<td>" . $row[2] . "</td>
<td>" . $row[3] . "</td>
<td class='warning'>" . $row[4] . "</td>
<td class='warning'>" . $row[5] . "</td>
<td>" .$row4_info.$row5_info."</td></tr>";
}
else {
echo "<tr><td>" . $sn = $startpoint + $count .
"</td><td class='C{$count}'>" .$row[0] ."</td>
<td>" . $row[1] . "</td>
<td>" . $row[2] . "</td>
<td>" . $row[3] . "</td>
<td>" . $row[4] . "</td>
<td>" . $row[5] . "</td>
<td>" . "<input type='text' id='{$row[0]}'
class='A{$count}' value='' />" . "</td></tr>";
}
$count = $count +1;
}
echo "</table>";
echo "<button style='margin-left:30px' id='save' class='button btn-submit btn btn-primary' name='save'>Save</button>";
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<script src="js/jquery.tabletojson.min.js" type="text/javascript"></script>
<script src="js/jquery-2.2.3.js" type="text/javascript"></script>
<head>
<script type="text/javascript">
$(document).ready(function() {
$('#save').click( function() {
var table = $('#example-table').tableToJSON();
console.log(table);
alert(JSON.stringify(table));
});
});
我希望在json中获取所有表值,当我点击保存按钮时它们会在警告框中显示所有值。输入文本框值不显示在json.how中我可以解决这个问题你可以在下面的链接中看到图像 http://www.aventissoft.net/deve/json/json.png
答案 0 :(得分:0)
更新你的while循环:
$ valgrind --tool=exp-sgcheck ./a.out
==10485== exp-sgcheck, a stack and global array overrun detector
==10485== NOTE: This is an Experimental-Class Valgrind Tool
==10485== Copyright (C) 2003-2015, and GNU GPL'd, by OpenWorks Ltd et al.
==10485== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==10485== Command: ./a.out
==10485==
==10485== Invalid read of size 1
==10485== at 0x4C2A374: strlen (h_intercepts.c:131)
==10485== by 0x4E9DD5B: puts (in /usr/lib64/libc-2.22.so)
==10485== by 0x4005C8: main (v.c:11)
==10485== Address 0xfff00042a expected vs actual:
==10485== Expected: stack array "string1" of size 10 in frame 2 back from here
==10485== Actual: unknown
==10485== Actual: is 0 after Expected
==10485==
==10485== Invalid read of size 1
==10485== at 0x4EA9BA2: _IO_default_xsputn (in /usr/lib64/libc-2.22.so)
==10485== by 0x4EA7816: _IO_file_xsputn@@GLIBC_2.2.5 (in /usr/lib64/libc-2.22.so)
==10485== by 0x4E9DDF7: puts (in /usr/lib64/libc-2.22.so)
==10485== by 0x4005C8: main (v.c:11)
==10485== Address 0xfff00042a expected vs actual:
==10485== Expected: stack array "string1" of size 10 in frame 3 back from here
==10485== Actual: unknown
==10485== Actual: is 0 after Expected
==10485==
123456789123456789
==10485==
==10485== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
也可以尝试使用console.log()代替警报。由于长字符串在警报中,它无法显示整个事物