简体   繁体   English

单击单选按钮和提交按钮时隐藏表格列

[英]Hide a table column when a radio button is clicked with a submit button

I am trying to hide a table column for two of my radios and to show for one. 我正在尝试隐藏两个收音机的表列,并显示一个。 So far I have tried many solutions but non are functional. 到目前为止,我已经尝试了许多解决方案,但是没有解决方案。

here are my radios, 这是我的收音机,

<input type='radio'  name='users' value='all' <?php if (isset($_POST['users']) && $_POST['users'] == 'all')  echo ' checked="checked"';?> checked /> All Candidates<br> 
              <input type='radio'  name='users' value='approved' <?php if (isset($_POST['users']) && $_POST['users'] == 'approved') echo ' checked="checked"';?> / > Approved Candidates<br>
              <input type='radio' id='show' name='users' value='unapproved'  <?php if (isset($_POST['users']) && $_POST['users'] == 'unapproved')  echo ' checked="checked"';?> /> Unapproved Candidates<br><br> 
             <input type="submit" value="submit" id="submit"><br><br>

My column is 我的专栏是

<th>Check for Approval <input type="checkbox" id="select_all"/> </th>

And here follows my jQuery, 然后是我的jQuery,

 <script>
        $(function() {

            $(':radio' ).change(function(){

                var isChecked = $('#show').prop('checked');
                $('#select_all').toggle(isChecked);
            });

        });
            </script>

On applying this ,what I have received so far is on clicking the radio button only the checkbox in the table header goes off for two of my radios but submit button makes that appear again. 到目前为止,我收到的关于单击此单选按钮的信息仅是表标题中两个我的单选按钮的复选框都关闭了,但是“提交”按钮使该复选框再次出现。 So no luck yet on this. 所以还没有运气。 Hope to find some solution regarding that. 希望找到一些解决方案。

您可以使用jquery隐藏第n个子项(如果它始终是同一列)。

$('th:nth-child(2),td:nth-child(2)').hide()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM