I need to create a comma separated value for a hidden input created from a series of div id's
<div id="main">
<div id="A"></div>
<div id="B"></div>
<div id="C"></div>
</div>
<input type="hidden" id="children"/>
I want to use jquery but having trouble with the function
function update_input(main){
var array = new Array();
$('#'+main).children('id').each(function(){
array.push($(this).attr('div'));
});
input_value = array.toString();
$('#children').val(input_value);
}
This is not right
$('div','#main').each(function(){
array.push($(this).attr('id'));
});