获取表单内容(一个方法获取所有表单的值)
//获取表单内容,要求id把#传过来 如果传餐 "#fromId"
function getFormValues(formId){
var params={};
$(formId).find("input[type='text']").each(function(i) {
var id = this.id;
var value = this.value;
params[id] = value;
});
$(formId).find("input[type='hidden']").each(function(i) {
var id = this.id;
var value = this.value;
params[id] = value;
});
$(formId).find("input[type='password']").each(function(i) {
var id = this.id;
var value = this.value;
params[id] = value;
});
$(formId).find("textarea").each(function(i) {
var id = this.id;
var value = this.value;
params[id] = value;
});
$(formId).find("select").each(function(i) {
var id = this.id;
var value = $("#"+this.id).find("option:selected").text();
params[id] = value;
});
$(formId).find("input[type='number']").each(function(i) {
var id = this.id;
var value = this.value;
params[id] = value;
});
return params;
}