I have this html:
You have almost correct code. The only one bug is that you are storing changed select name in variable id, and then using it in string creation. This should work correctly:
$("select").change(function () {
var str = "";
$("select option:selected").each(function () {
str += '&' + $(this).parent().attr('name') + "="+ $(this).attr('value');
});
$("div").text(str);
});
And simple optimization is always a good practice :)
$("select").change(function () {
var str = "";
$("select option:selected").each(function () {
var option = $(this);
str += '&' + option.attr('name') + "="+ option.attr('value');
});
$("div").text(str);
});