<script>
function check()
{
if((document.all.title.value=="")&&(document.all.writer.value=="")&&(document.all.myclass.value=="all"))
{
if(confirm("确认按默认条件显示数据库所有记录吗?"))
form1.submit();
}
else
form1.submit();
}
</script>
<form name=form1 action=search.jsp>
        <table width="75%" border="0" cellspacing="1" cellpadding="1" class="kmwin" bgcolor="#000000">
          <tr bgcolor="#d1d9e2"> 
            <td colspan="2" align="center" height="43"><b class="kmwin">搜 索 帖 
              子</b> </td>
          </tr>
          <tr> 
            <td width="20%" align="center" bgcolor="#f0f3fa" height="43">主题:</td>
            <td width="80%" bgcolor="#fafbfc" height="43" align="center"> 
             <input type=text name=title size="54"> 
            </td>
          </tr>
  <tr> 
            <td width="20%" align="center" bgcolor="#f0f3fa" height="43">分类:</td>
            <td width="80%" bgcolor="#fafbfc" height="43" align="center"> 
           <select name="myclass">
   <option value="all" seleced>全部
   <option value="开发信息">开发信息
   <option value="CAD">CAD
   <option value="CAPP">CAPP
   <option value="BOM">BOM
           <option value="PDM">PDM
   <option value="其它">其它
</td>
          </tr>
          <tr> 
            <td width="20%" align="center" bgcolor="#f0f3fa" height="43">发起人:</td>
            <td width="80%" bgcolor="#fafbfc" height="43" align="center"> 
            <input type=text name=writer>
            </td>
          </tr>
          <tr align="center"> 
            <td colspan="2" height="43" bgcolor="#fafbfc"> 
              <input name=ok type=button onclick=check() name=search value="查询">
              &nbsp;&nbsp; 
              <input type=reset value=清除 name="reset">
            </td>
          </tr>  
  </tbody> 
</table>
</form>

解决方案 »

  1.   

    <Form Action="*.asp" Method="Post" Name="TheForm">
      <Input Type=Text Name="oText">
      <Select Name="TheList">
        <Option Value="" Selected>无选择</Option>
        <Option Value="China">China</Option>
        <Option Value="Japan">Japan</Option>
        <Option Value="Korea">Korea</Option>
      </Select>
      <Input Type=Button Value="提交" OnClick="Check()">
    </Form>
    <Script Language="JavaScript">
      <!--
        function Check() {
          if( TheForm.oText.value=="" && TheForm.TheList.value=="" ) 
              if( confirm("系统将显示数据库中所有数据,请问是否继续?") )
                 //查询所有数据
                   else
                      // 其它
        }
      -->
    </Script>
      

  2.   

    那就这样遍历文本框,注意//////////////////////之间的为添加的代码
    <script>
    function check()
    {
    //////////////////////
    ok=false;
    for(var m=0;m<form1.elements.length;m++){
    var ob=form1.elements[m];
    if(ob.type=="text"){
    if(ob.value!="")
                            {ok=true;
    break;
    }
    }
    }
    //////////////////////
    if((!ok)&&(document.all.myclass.value=="all"))
    {
    if(confirm("确认按默认条件显示数据库所有记录吗?"))
    form1.submit();
    }
    else
    form1.submit();
    }
    </script>
    <form name=form1 action=search.jsp>
            <table width="75%" border="0" cellspacing="1" cellpadding="1" class="kmwin" bgcolor="#000000">
              <tr bgcolor="#d1d9e2"> 
                <td colspan="2" align="center" height="43"><b class="kmwin">搜 索 帖 
                  子</b> </td>
              </tr>
              <tr> 
                <td width="20%" align="center" bgcolor="#f0f3fa" height="43">主题:</td>
                <td width="80%" bgcolor="#fafbfc" height="43" align="center"> 
                 <input type=text name=title size="54"> 
                </td>
              </tr>
      <tr> 
                <td width="20%" align="center" bgcolor="#f0f3fa" height="43">分类:</td>
                <td width="80%" bgcolor="#fafbfc" height="43" align="center"> 
               <select name="myclass">
       <option value="all" seleced>全部
       <option value="开发信息">开发信息
       <option value="CAD">CAD
       <option value="CAPP">CAPP
       <option value="BOM">BOM
               <option value="PDM">PDM
       <option value="其它">其它
    </td>
              </tr>
              <tr> 
                <td width="20%" align="center" bgcolor="#f0f3fa" height="43">发起人:</td>
                <td width="80%" bgcolor="#fafbfc" height="43" align="center"> 
                <input type=text name=writer>
                </td>
              </tr>
              <tr align="center"> 
                <td colspan="2" height="43" bgcolor="#fafbfc"> 
                  <input name=ok type=button onclick=check() name=search value="查询">
                  &nbsp;&nbsp; 
                  <input type=reset value=清除 name="reset">
                </td>
              </tr>  
      </tbody> 
    </table>
    </form>
      

  3.   

    谢谢seabell(百合心) 
    谢谢MAGICSLIAO(MagicsLiao)