javascript - 单击提交按钮并将数据插入 php 中的数据库表时如何显示隐藏表?

标签 javascript php jquery html mysql

我有一个,通过它我输入项目名称和工作表名称,它们将保存在项目表中。基于此,我在另一个表“数据”上插入空值。我正在使用可编辑表来更新数据库中的这些空值。我想隐藏此表,直到提交项目名称和工作表名称,一旦提交值,则只显示表格。我已经尝试了很多,但在单击提交按钮后,我的表格会显示,直到页面重新加载并在加载完成时消失。我的代码部分如下。

    <script>
     $(function(){
     $('button#showit').on('click',function(){  
    $('#myform').show();
     });
     });
    </script>
    <form class="form-horizontal" action="db.php" id="#form1" 
     onSubmit="function();" method="post">

    <input type="text" class="form-control1" name="projectname" 
   id="projectname" required >
    <input type="text" class="form-control1" name="sheetname" id="sheetname" 
    required >
    <button type="submit" name="submit" id="button" class="btn-
     success btn" >Submit</button>
        </form>
      <div class="tab-content"  id="myform" style="display:none">
     <div class="tab-pane active" id="horizontal-form">
     <?php 

       $s4 = "SELECT * FROM data ORDER BY data_id DESC LIMIT 1";
     $res = mysqli_query($bd, $s4);
    while ($row = mysqli_fetch_array($res))
                                 {
                            ?>  
   <table class="table table-bordered" style="width:50%;">
    <thead>
    <tr>
    <th>Sr.no</th>
    <th>Column Name</th>

       </tr>
     </thead>
     <tbody>

   <tr class="odd">
    <td>1</td>
     <td id="d1:<?php echo $row['data_id']; ?>" contenteditable="true"><?php 
    echo $row['d1']; ?></td>          
   </tr>

   .
   .
    .
   </tbody>
    </table>
   <?php } ?>
   </div>
   </div>
 on db.php I have used to get back on my previous page
    <script>
                    alert('Sheet Created Successfully');
                    window.location.href='index.php?success';

   </script>

最佳答案

<!-- Example of jQuery Reference -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<!-- Your Hiding Script -->
<script type='text/javascript'>
    $(document).ready(function(){
      $("#AddNewRecord").hide();
    });
</script>

<!-- Your Markup -->
<table border="1" cellpadding="2" id="AddNewRecord">
    <tr style="width:25px;">
        <td>Site</td>
    </tr>
</table>

关于javascript - 单击提交按钮并将数据插入 php 中的数据库表时如何显示隐藏表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44450778/

相关文章:

javascript - PHP Ajax MySQL 表行删除

php - 按列对表格中的数据进行排序

javascript - Jquery $(window).height() 函数不返回实际窗口高度

javascript - 如何为 NetSuite 中的 HTML 元素提供 DOM 中的 ID?

javascript - 在 Document.write() 之后调用函数时遇到问题

javascript - jQuery – 在滚动的特定点处/之后添加一个类,上面有可变长度的内容

javascript - 仅刷新首页

php - 你如何使用php插入到mysql数据库中?

javascript - 如何在具有按钮元素的情况下在 "show more"和 "show less"之间切换?

javascript - 如何解析addListener javascript中的数据