Created
January 31, 2012 02:54
-
-
Save irasally/1708418 to your computer and use it in GitHub Desktop.
値の入っている要素のみをパラメーターとしてgetURLを生成する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
document.location.href = action + '?' + params; | |
} |
パフォーマンスが良くなかったところを教えてもらったのでなおす
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
もう少し良いコードを考える