1,动态提交表单
<script language="javascript">
function toInsert(){
var frm=document.getElementById("userFrm")
var msg = checkData();
if(msg.length>1){
alert(msg);
return ;
}
frm.action="/quickUpdatePwd.do"
frm.submit();
}
</script>
2.清空表单
<script language="javascript">
function reSetForm(formName){
var f=document.getElementById(formName).elements;
for(var i=0; i<f.length; i++){
f[i].disabled='';
switch(f[i].type){
case "text":
f[i].value=''
case "password":
f[i].value=''
case "file":
f[i].value=''
case "textarea":
f[i].value=''
case "checkbox":
f[i].checked=false;
case "select-one":
f[i].selectedIndex=0;
case "select-multiple":
f[i].selectedIndex=0;
}
}
document.getElementById(f[0].name).focus();
}
</script>
3.从表单中取值存入数组:
<script language="javascript">
function getForm(formName){
var f=document.getElementById(formName).elements;
var ary = new Array();
for(var i=0; i<f.length; i++){
f[i].disabled='';
switch(f[i].type)
{
case "text":
ary[i] = f[i].value;
case "password":
ary[i] = f[i].value;
case "file":
ary[i] = f[i].value;
case "textarea":
ary[i] = f[i].value;
case "checkbox":
ary[i]=f[i].value;
case "radio":
ary[i]=f[i].value;
case "select-one":
ary[i] = f[i].value;
case "select-multiple":
ary[i] = f[i].value;
}
}
return ary;
}
</script>