Skip to content

Instantly share code, notes, and snippets.

@irasally
irasally / create_get_url_from_elements
Created January 31, 2012 02:54
値の入っている要素のみをパラメーターとしてgetURLを生成する
function submit(form, action){
var params = '';
var el;
var i = form.elements.length;
while(i--){
el = form.elements[i];
if(el.type !== 'submit' && el.value !== ''){
if((el.type === 'checkbox' || el.type === 'radio') && !el.checked) continue;
if(params.length > 0) params += '&';
params += el.name + '=' + el.value;