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 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I want only certain buttons to be displayed through jquery

    I have a grid of buttons ehere user onpens up the gird by clicking on the (Open Grid) link and then clicking on a button in that grid. What will then happen is that a set of buttons appear below the text box depending on the button selected from the grid. So if user select button "1" then button "A" appears, if user selects button "2" then buttons "A" and "B" appears and so on.

    Now this is done through jquery code below:

    $(".gridBtns").click(function() {

    var clickedNumber = this.value;

    $('.answerBtns').each(function (index) {
    if (index < clickedNumber)
    $(this).show();
    else
    $(this).hide();
    });

    });

    But what I want to do is that if user selects button "True or False" from the grid, I want only the buttons "True" and "False" under the text box and if user selects "Yes or No" button from the gird, then I only want buttons "Yes" and "No" to display under the text box, How can this be do in my jquery code?

    Also if user selects "True or False" button or "Yes or No" button, then I want the "Number of Answers" text box to disappear and display the span tag "N/A" only, does anyone know to do this in jquery.

    Thanks and code is in jsfiddle, click [here][1]


    [1]: http://jsfiddle.net/pSy97/10/

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Code:
    $(".gridBtns").click(function() {
    
       var clickedNumber = this.value;
    
       $('.answerBtns').each(function (index) {
          if (index < clickedNumber)
             $(this).show();
          else
             $(this).hide();
       });
    
        if(clickedNumber == "True or False") {
          $('#answerTrue').show();
          $('#answerFalse').show();
        }
        if(clickedNumber == "Yes or No") {
          $('#answerYes').show();
          $('#answerNo').show();
        }
    });


  •  

    Posting Permissions

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