Created
January 31, 2012 02:54
-
-
Save irasally/1708418 to your computer and use it in GitHub Desktop.
値の入っている要素のみをパラメーターとしてgetURLを生成する
This file contains hidden or 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; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
パフォーマンスが良くなかったところを教えてもらったのでなおす