Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-11-2011, 01:59 PM   PM User | #1
malcolm p
New Coder

 
Join Date: Dec 2011
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
malcolm p is an unknown quantity at this point
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/
malcolm p is offline   Reply With Quote
Old 12-12-2011, 06:52 AM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,261
Thanks: 10
Thanked 533 Times in 527 Posts
devnull69 will become famous soon enough
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();
    }
});
devnull69 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:56 AM.


Advertisement
Log in to turn off these ads.