简体   繁体   中英

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,

 <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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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