Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    JAG
    JAG is offline
    New Coder
    Join Date
    Feb 2011
    Posts
    63
    Thanks
    24
    Thanked 0 Times in 0 Posts

    Question jQuery Form Crashes when Radio Button is Clicked

    I have this form that uses jQuery. It works great except for one thing: When a user clicks the radio button called "Isuzu NPR-HD-Gas," the page's layout crashes! This happens in every browser. All of the other options in the form work great, it's just this one radio button that causes the problem. What can be causing this problem?

    Here's the link: http://www.unitedtruckcenters.com/cu...mpare-to-isuzu

    Note: Please scroll down and click on "Isuzu NPR-HD-Gas" to see what I am talking about.
    Last edited by JAG; 09-19-2013 at 05:18 PM.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,033
    Thanks
    0
    Thanked 248 Times in 245 Posts
    Because of these:
    Code:
    $('td:nth-child(' + show + '),th:nth-child(' + show + ')').show();
    $('td:nth-child(' + hide + '),th:nth-child(' + hide + ')').hide();
    The selectors are using td which is too general. All td's on the page will match those selectors. Narrow the selector by specifying which table(s) you want to be matched. If it's only for one table, you can specify the table id. If multiple tables, specify the table class.

    Code:
    $('#myTable td:nth-child(' + show + '), #myTable th:nth-child(' + show + ')').show();
    $('#myTable td:nth-child(' + hide + '), #myTable th:nth-child(' + hide + ')').hide();
    or
    Code:
    $('.myTableClass td:nth-child(' + show + '), .myTableClass th:nth-child(' + show + ')').show();
    $('.myTableClass td:nth-child(' + hide + '), .myTableClass th:nth-child(' + hide + ')').hide();

  • Users who have thanked glenngv for this post:

    JAG (09-19-2013)

  • #3
    JAG
    JAG is offline
    New Coder
    Join Date
    Feb 2011
    Posts
    63
    Thanks
    24
    Thanked 0 Times in 0 Posts
    It worked like I wanted it to after I took out out those two lines.
    Thank you, Glenn!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •