I have a web project which I inject some question with created html code into the html page. Since these html object created dynamically I do not know how many questions will be and what will be their IDs. I need to get the selected answers.

Here there is a piece of html code created dynamically and some javascript functions with JSFiddle demo. nextPage function where I try to get the selected answers do not work.

```
function nextPage() {
var results = new Array();
var contents = $(this).parents("div").parents("div").find("input");
contents.filter(":checked").each(function () {
    var idx = $(this).index();
    results.push($(this).parent().children().get(idx + 1).innerHTML);
    alert($(this).parent().children().get(idx + 1).innerHTML);
});
contents.filter(":text").each(function () {
    results.push($(this).val());
});

alert(results.join(";"));
pageNumber += 1;
window.location = '#question' + pageNumber;
}

```

[JSFiddle Demo](http://jsfiddle.net/REthD/2/) 

How can I get the selected answers? Any help will be appreciated.