Skip to content

Instantly share code, notes, and snippets.

@iruslani
Created June 6, 2012 18:52
Show Gist options
  • Save iruslani/2883876 to your computer and use it in GitHub Desktop.
Save iruslani/2883876 to your computer and use it in GitHub Desktop.
This is an example of how to use a jquery variable inside a selector
$('form#zaav_a input:radio, form#zaav_b input:radio').click(function(){
// store variable class in this variable:
whichOne = $(this).attr("class");
// use variable name as a selector to select twin radio button mark as checked:
$('.' +whichOne).attr("checked", "checked");
getPCS = $('input:radio[name=pcs]:checked').val();
getYears = $('input:radio[name=years]:checked').val();
alert('years: ' +getYears+ 'pcs: ' +getPCS);
$('.button_url').attr({href:'http://www.test.htm?product=ZAAV-'+getYears+'year-'+getPCS+'user'});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment