views:

66

answers:

2

Hi I am trying to set href using Jquery inside click event of RadioButtonList but that doesnt work If I take the same code to document.ready event it works fine but not in click event. Please advice.

$(document).ready(function() {    
   url = "Results.aspx?latitude=" +latitude + "&Longitude=" + longitude;

 $("a[href='http://www.google.com/']").attr("href", url); // this works..
        }        
        $('.rbl input').click(function() {

            id = $(this).parent().children("input").val();
            url = "Results.aspx?latitude=" + latitude + "&Longitude=" + longitude + "&ServiceCenterProductTypeId=" + id;
            //alert(url);
            $("a[href='http://www.google.com/']").attr("href", url); //this doesnt work....

        });
    });
+4  A: 

Looks to me like you have an extra closing curly bracket } after this line:

$("a[href='http://www.google.com/']").attr("href", url); // this works..
patrick dw
A: 

You (probably) have the AutoPostBack property set to true, causing a postback to the server which reloads the entire page.

Therefore, your changes in Javascript are overwritten by the postback.

SLaks