日期:2014-05-17  浏览次数:20836 次

点击追加后,原来输入过的数据被清空,求解决办法(下附代码)
表单如下:
<form   name= "insert "   method= "post "   >
<table   input   type= "hidden "   width= "700 "   border= "0 "   cellspacing= "1 "   cellpadding= "3 "   align= "center "   bgcolor= "#006699>
<tr   bgcolor= "FFFFFF "   align= "center ">
<td   bgcolor= "#C0D9E6 "   width= "17% "> <DIV   align=center> NO </DIV> </td>
<td   bgcolor= "#C0D9E6 "   width= "17% "> <DIV   align=center> NAME </DIV> </td>
<td   bgcolor= "#C0D9E6 "   width= "17% "> <DIV   align=center> AGE </DIV> </td>
<td   bgcolor= "#C0D9E6 "   width= "17% "> <DIV   align=center> JOB </DIV> </td>
<td   bgcolor= "#C0D9E6 "   width= "17% "> <DIV   align=center> BIRTHDAY </DIV> </td>
<td   bgcolor= "#C0D9E6 "   width= "15% "> </td>
</tr>
<tr   bgcolor= "FFFFFF "   align= "center ">
<td   width= "17% "> <input   type= "text "   maxlength= "6 "   name= "ano "   id= "ano "   value= " "> </td>
<td   width= "17% "> <input   type= "text "   name= "aname "   id= "aname "   value= " "> </td>
<td   width= "17% "> <input   type= "text "   maxlength= "2 "   name= "aage "   id= "aage "   value= " "> </td>
<td   width= "17% "> <input   type= "text "   name= "ajob "   id= "ajob "   value= " "> </td>
<td   width= "17% "> <input   type= "text "   maxlength= "10 "   name= "abirth "   id= "abirth "   value= " "> </td>
<td   width= "15% "> <input   type= "submit "   name= "insert "   id= "insert "   value= "追加 "
onClick= "JavaScript:aInsert() "> </td>
</tr>
</table>
</form>


函数如下:
<Script   language=JavaScript>
      function   aInsert(){
      var   gno=document.getElementById( "ano ").value;
      var   gname=document.getElementById( "aname ").value;
      var   gage=document.getElementById( "aage ").value;
      var   gjob=document.getElementById( "ajob ").value;
      var   gbirth=document.getElementById( "abirth ").value;

      if   (gno   ==   " "   )  
{alert( "please   enter   your   NO ");}
      else   if(gname   ==   " "   )
{alert( "please   enter   your   NAME ");}
      else   if(gage   ==   " "   )
{alert( "please   enter   y