首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

依据一个id返回web页面所有的参数

2012-11-25 
根据一个id返回web页面所有的参数function getFormQueryString(frmID){ var frmIDdocument.getElementByI

根据一个id返回web页面所有的参数
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;

}

热点排行