Quote:
Originally Posted by logic ali
Code:
function getGroupValue( group ) /* group == radio/checkbox single/group or <select> options list */
{
var selectedElems = [],
g;
if( group.length === undefined )
{
if( group.checked || group.selected )
selectedElems.push( group.value );
}
else
for( g = 0; group[ g ]; ++g )
if( group[ g ].checked || group[ g ].selected )
selectedElems.push( group[ g ].value );
return selectedElems.length > 0 ? selectedElems : null;
}
|
wow!!!
I like the idea of one function to collect information from different element types.
Less typing, less prone to errors, common implementation, understandable and neat all rolled-up into one small package.
Thanks for the attention to the topic, 'Logic Ali'.
Added to the "Post A JavaScript" section of this forum. See:
http://www.codingforums.com/showthre...64#post1300264