function FormSearchCommerc(SearchForm) { ClassElements = document.getElementsByName('sc[]'); for (var i = 0; i < ClassElements.length; i++) { ClassElement=ClassElements[i]; ProfileElements = document.getElementsByName('sp_'+ClassElement.value); for (var j = 0; j < ProfileElements.length; j++) { ProfileElement=ProfileElements[j]; if (ProfileElement.checked) { new_element = document.createElement('input'); new_element.name = 'sp['+ClassElement.value+']['+j+']'; new_element.value = ProfileElement.value; SearchForm.appendChild(new_element); } } } SearchForm.submit(); }