gpt4 book ai didi

php - 输入框字段值不以json格式显示

转载 作者:行者123 更新时间:2023-11-30 22:19:40 25 4
gpt4 key购买 nike

<?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 中。我该如何解决这个问题,您可以在下面的链接中看到图像 http://www.aventissoft.net/deve/json/json.png

最佳答案

更新你的 while 循环:

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;
}

另外,尝试使用 console.log() 而不是警报。由于字符串过长而处于警报状态,因此无法显示全部内容

关于php - 输入框字段值不以json格式显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36997441/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com