douba8048 2016-09-21 21:44
浏览 26

使用实时表单的Jquery HTML表问题

I have a update form which updates SQL tables.

The form is working fine, issue is with the HTML portion. When clicking on the table cell a pop up box appears, but for some reason a new column is being added causing the HTML to break down.

enter image description here

I have tried making changes in the JS but no luck so far. Anyone can tell what is wrong here?

<?php
include("connect.php");
?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />    
    <meta charset="utf-8">
    <title>Update Form</title>   
    <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="assets/css/custom.css" rel="stylesheet" type="text/css">
</head>
<body>

    <div class="container">    

                <div class="row">
                    <table class= "table table-striped table-bordered table-hover">
                        <thead>
                            <tr>

                                <th colspan="1" rowspan="1" style="width: 180px;" tabindex="0">Name</th>

                                <th colspan="1" rowspan="1" style="width: 220px;" tabindex="0">Description</th>

                                <th colspan="1" rowspan="1" style="width: 288px;" tabindex="0">Status</th>
                            </tr>
                        </thead>

                        <tbody>
                        <?php
                        $sql = "EXEC dbo.sp_GOMDailyProd @Action = 'Read'";  
                        $query = sqlsrv_query($connect, $sql);  
                        $i=0;
                        while($fetch = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC))
                        {
                            if($i%2==0) $class = 'even'; else $class = 'odd';

                            echo'<tr class="'.$class.'">

                                <td class="xedit" id="'.$fetch['MerrickID'].'" key="name">'.$fetch['OilProd'].'</td>
                                <td class="xedit" id="'.$fetch['MerrickID'].'" key="details">'.$fetch['OilProd'].'</td>
                                <td class="xedit" id="'.$fetch['MerrickID'].'" key="status">'.$fetch['OilProd'].'</td>
                            </tr>';                         
                        }
                        ?>
                        </tbody>
                    </table>
        </div>
        <script src="assets/js/jquery.min.js"></script> 
        <script src="assets/js/bootstrap.min.js"></script>
        <script src="assets/js/bootstrap-editable.js" type="text/javascript"></script> 
<script type="text/javascript">
jQuery(document).ready(function() {  
        $.fn.editable.defaults.mode = 'popup';
        $('.xedit').editable();     
        $(document).on('click','.editable-submit',function(){
            var key = $(this).closest('.editable-container').prev().attr('key');
var x = $(this).closest('.editable-container').prev().attr('id');
var y = $('.input-sm').val();
var z = $(this).closest('.editable-container').prev().text(y);

            $.ajax({
                url: "process.php?id="+x+"&data="+y+'&key='+key,
                type: 'GET',
                success: function(s){
                    if(s == 'status'){
                    $(z).html(y);}
                    if(s == 'error') {
                    alert('Error Processing your Request!');}
                },
                error: function(e){
                    alert('Error Processing your Request!!');
                }
            });
        });
});
</script>
    </div>
</body>
</html>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!