<form id="myForm">
<input name="test" value="blabla" />
<textarea name="area">Тестовый текст</textarea>
</form>
<script type="text/javascript">
function serializeForm( form ) {
var result = '', gE = 'getElementsByTagName',
inputs = [ form[ gE ]('input'), form[ gE ]('select'), form[ gE ]('textarea'), form[ gE ]('button') ],
iln = inputs.length, eln, i, j, name;
for( i = 0; i < iln; i++ ) {
eln = inputs[ i ].length;
for( j = 0; j < eln; j++ ) {
if ( inputs[ i ][ j ] ) {
if ( name = inputs[ i ][ j ].getAttribute( 'name' ) ) {
result += escape( name ).replace( /\+/g, '%2B' );
result += '=' + escape( inputs[ i ][ j ].value ).replace( /\+/g, '%2B' ) + '&';
}
}
}
}
return result;
}
alert( serializeForm( document.getElementById('myForm') ) );
</script>