send(){
// console.log(json)
this.getElements("form1",'type')
this.getElements("form2",'father')
this.getElements("form3",'mather')
this.getElements("form4",'child')
this.getElements("form5",'visit')
},
//formName:锁定表单的id
// elementName:表单中元素的name属性
getElements(formName,elementName) {
//遍历所有的form表单
for(var f=0;f<document.forms.length;f++){
var form=document.forms[f];
// console.log(form,'form');
if(form.name==formName){
// console.log(form.name,'name');
//遍历指定form表单所有元素
for(var i=0;i<form.length;i++){
var element=form[i];
if(element.name==elementName){
if (element.value==='') {
// plus.nativeUI.toast('出生日期不能为空!');
// console.log(element,'222');
element.placeholder='该行不能为空'
}
else{
// 定义一个新数组,将获取到的value值添加到数组中
this.info.push(element.value)
this.info.push(element.id)
//
}
}
}
break;
}
}
// 定义一个json空对象,将数字转化为json对象
for(let i = 0; i < this.info.length; i+=2){
this.jsonInfo[this.info[i+1]] = this.info[i]
}
console.log(this.info,'info');
console.log(this.jsonInfo,'jsonInfo');
}