日期:2014-05-16 浏览次数:20342 次
function getFormQueryString(frmID)
{
var frmID=document.getElementById(frmID);
var i,queryString = "", and = "";
var item; // for each form's object
var itemValue;// store each form object's value
for( i=0;i<frmID.length;i++ ){
item = frmID[i];// get form's each object
if( item.name!='' ){
if( item.type == 'select-one' ){
itemValue = item.options[item.selectedIndex].value;
}else if( item.type=='checkbox' || item.type=='radio') {
if ( item.checked == false ){
continue;
}
itemValue = item.value;
}else if( item.type == 'button' || item.type == 'submit' || item.type == 'reset' || item.type == 'image'){// ignore this type
continue;
}else{
itemValue = item.value;
}itemValue = encodeURIComponent(itemValue);
queryString += and + item.name + '=' + itemValue;
and="&";
}
}
return queryString;
}