Reddy
Reddy

Reputation: 1385

How to show <tr> tag on clicking button and prevent page refresh

My Requirement is to hide a tag initially, if user clicks forwardbutton without checking any radio or checkbutton we have show the tag and have to prevent page refresh. But it is permanently not submitting on click, Plese someone help me.

$(document).ready(function()
{
var y=$('input').filter(':checked').length;
alert(y);
if(y == 0 )
{
   $('#Q1_7_label').parents('TR').hide();       
}
$('#forwardbutton').live('click',function(event)
 {
    var x=$('input').filter(':checked').length;
    if(x==0)
     {
      $('#Q1_7_label').parents('TR').show(); 
      return false;
     }
 });

});

Upvotes: 0

Views: 268

Answers (2)

Gustav Barkefors
Gustav Barkefors

Reputation: 5086

Try to replace

return false;

with

event.preventDefault();

Upvotes: 1

Balanivash
Balanivash

Reputation: 6867

$('#forwardbutton').live('click',function(event)
 {
    var x=$('input').filter(':checked').length;
    if(x==0)
     {
      $('#Q1_7_label').parents('TR').show(); 
      return false;
     }
     return true;
 });

Just add return true at the end of the function

Upvotes: 1

Related Questions