Hi, i'm sure this is just a simple one, but its got me stumped on a few different projects now.. i have to keep declaring my variables, and i'm sure there is a better way to be doing things.
in the example below, i'm finding at the "#gender" stage "gender" is printing out fine, but "#age" stage "gender" is no longer defined &/or is not being carried through to the other function.
an example:
var gender;
var age;
var children;
$('#gender li:contains(Male)').click(function() {
gender = "male";
$('#age').show();
$('span.jquery_out').text(gender);
});
$('#gender li:contains(Female)').click(function() {
gender = "female";
$('#age').show();
$('span.jquery_out').text(gender);
});
$('#age li:contains(1)').click(function() {
var age = "1";
$('#children').show();
$('span.jquery_out').text(gender+" -> "+age);
});
$('#age li:contains(2)').click(function() {
var age = "2";
$('#children').show();
$('span.jquery_out').text(gender+" -> "+age);
});
$('#age li:contains(3)').click(function() {
var age = "3";
$('#children').show();
$('span.jquery_out').text(gender+" -> "+age);
});
$('#age li:contains(4)').click(function() {
var age = "4";
$('#children').show();
$('span.jquery_out').text(gender+" -> "+age);
});
$('#age li:contains(5)').click(function() {
var age = "5";
$('#children').show();
$('span.jquery_out').text(gender+" -> "+age);
});
Hope someones got an answer, i'm sure its not a tricky one when in the know. Thanks in advanced. Matt