首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

请大家帮小弟我看看小弟我的复选框判断~没头绪了~多谢了

2012-03-20 
请大家帮我看看我的复选框判断~没头绪了~谢谢了我这是图书馆查询页面,里面有复选框和单选按钮,查询提交时

请大家帮我看看我的复选框判断~没头绪了~谢谢了
我这是图书馆查询页面,里面有复选框和单选按钮,查询提交时无论单选或多选至少选一个,就是如果不选单选就要有一个复选,如果复选不选就要有一个单选~代码如下:

<%@LANGUAGE= "VBSCRIPT "   CODEPAGE= "936 "%>

<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 ">
<title> 书籍查询 </title>

<link   href= "css/yangshi.css "   rel= "stylesheet "   type= "text/css ">
<style   type= "text/css ">
<!--
.style8   {color:   #FF0000}
-->
</style>
<script   language= "javascript ">

function   checkvalue(theform)
{  
     
      for(j=0;j <theform.checkbox.length;j++)
      if(theform.checkbox(i).checked==true)
      {
    break;
        }
      for(i=0;i <theform.radiobutton.length;i++)
      if   (theform.radiobutton[i].checked==true)
      {
      break;
        }
if   (i==theform.radiobutton.length)
{
      alert( "您没选择任何查询项目 ");
      return   false;
}
return   (true);
}
</script>
<!--#include   file= "top.asp "-->

<table   width= "75% "     border= "0 "   align= "center ">
    <tr>
        <td   height= "27 "   class= "style4 "> <div   align= "center "> 书目查询 </div> </td>
    </tr>
</table>
<table   width= "75% "     border= "0 "   align= "center ">
    <tr>
        <td> <span   class= "style1 "> </span> 在这里,您可以对 </span> <span   class= "style8 "> 本馆图书 </span> 进行分类及详细查询 </td>
    </tr>
</table>
<form   name= "form1 "   method= "post "   action= "ac_booksearch.asp "   >
    <table   width= "68% "   height= "232 "     border= "0 "   align= "center ">
        <tr>
            <td   colspan= "2 "   > <span   class= "style6 "> 1.请选择查询路径 </span> </td>
        </tr>
        <tr   >
            <td   width= "15% "> </td>
            <td   width= "85% "   > <input   name= "radiobutton "   type= "radio "   value= "1 ">                
            <span   class= "style7 "> 编号 </span>
                <span   class= "style7 "> <input   name= "booknum "   type= "text "   id= "booknum ">
                </span> </td>
        </tr>


        <tr>
            <td> </td>
            <td   > <input   type= "radio "   name= "radiobutton "   value= "2 ">                
                <span   class= "style7 "> 书名
                <input   name= "bookname "   type= "text "   id= "bookname ">
                </span> </td>
        </tr>
        <tr   >
            <td> &nbsp; </td>
            <td   class= "style7 "> <input   type= "checkbox "   name= "checkbox "   value= "4 ">                
                <span   class= "style7 "> 内容
                <input   name= "content "   type= "text "   id= "content ">
                <input   type= "checkbox "   name= "checkbox "   value= "5 ">                
                作者
                </span>
                <input   name= "author "   type= "text "   id= "writer "> </td>
        </tr>
        <tr>
            <td> </td>
            <td   > <input   type= "radio "   name= "radiobutton "   value= "3 ">
                <span   class= "style7 ">   书籍分类
                <select   name= "bookclass "   id= "bookclass ">
                    <option   value= "1 "   selected> 马列主义、毛泽东思想、邓小平理论 </option>
                    <option   value= "2 "> 社会科学 </option>
                    <option   value= "3 "> 自然科学 </option>
                    <option   value= "4 "> 法律、哲学 </option>
                </select>
            </span> </td>
        </tr>
        <tr>
            <td> <span   class= "style6 "> 2.出版时间 </span> </td>
            <td> <input   name= "starttime "   type= "text "   id= "starttime ">


                <span   class= "style7 ">
                年-- </span>
                <input   name= "endtime "   type= "text "   id= "endtime ">
                <span   class= "style7 "> 年   (可不填) </span>   </td>
        </tr>
        <tr>
            <td   class= "style6 "> 3.每页显示条数 </td>
            <td> <span   class= "style7 "> <select   name= "rcperpage "   class= "style7 "   id= "rcperpage ">
                <option   value= "5 "> 5 </option>
                <option   value= "10 "> 10 </option>
                <option   value= "15 "> 15 </option>
            </select>
                条 </span> </td>
        </tr>
        <tr>
            <td   height= "21 "> &nbsp; </td>
            <td> &nbsp; </td>
        </tr>
        <tr   align= "center ">
            <td   height= "42 "   colspan= "2 "> <input   type= "submit "   name= "submit "   value= "查询 "   onClick= "javascript:checkvalue(this.form) ">   &nbsp;&nbsp;&nbsp;
            <input   type= "reset "   name= "reset "   value= "重填 "> </td>
        </tr>
    </table>
</form>


[解决办法]
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> Write The Codes By Myself </title>
<style type= "text/css ">
<!--
.style8 {color: #FF0000}
-->
</style>
<script language= "javascript ">

function checkvalue(theform)
{

for(j=0;j <theform.checkbox.length;j++)
if(theform.checkbox[j].checked==true)
{
break;
}
for(i=0;i <theform.radiobutton.length;i++)
if (theform.radiobutton[i].checked==true)
{
break;
}
if (i==theform.radiobutton.length && j==theform.checkbox.length)
{
alert( "您没选择任何查询项目 ");
return false;
}
return (true);
}
</script>

</head>

<body>
<table width= "75% " border= "0 " align= "center ">
<tr>
<td height= "27 " class= "style4 "> <div align= "center "> 书目查询 </div> </td>


</tr>
</table>
<table width= "75% " border= "0 " align= "center ">
<tr>
<td> <span class= "style1 "> </span> 在这里,您可以对 </span> <span class= "style8 "> 本馆图书 </span> 进行分类及详细查询 </td>
</tr>
</table>
<form name= "form1 " method= "post " action= "ac_booksearch.asp " onsubmit= "javascript:return checkvalue(this); ">
<table width= "68% " height= "232 " border= "0 " align= "center ">
<tr>
<td colspan= "2 " > <span class= "style6 "> 1.请选择查询路径 </span> </td>
</tr>
<tr >
<td width= "15% "> </td>
<td width= "85% " > <input name= "radiobutton " type= "radio " value= "1 ">
<span class= "style7 "> 编号 </span>
<span class= "style7 "> <input name= "booknum " type= "text " id= "booknum ">
</span> </td>
</tr>
<tr>
<td> </td>
<td > <input type= "radio " name= "radiobutton " value= "2 ">
<span class= "style7 "> 书名
<input name= "bookname " type= "text " id= "bookname ">
</span> </td>
</tr>
<tr >
<td> &nbsp; </td>
<td class= "style7 "> <input type= "checkbox " name= "checkbox " value= "4 ">
<span class= "style7 "> 内容
<input name= "content " type= "text " id= "content ">
<input type= "checkbox " name= "checkbox " value= "5 ">
作者
</span>
<input name= "author " type= "text " id= "writer "> </td>
</tr>
<tr>
<td> </td>
<td > <input type= "radio " name= "radiobutton " value= "3 ">
<span class= "style7 "> 书籍分类
<select name= "bookclass " id= "bookclass ">
<option value= "1 " selected> 马列主义、毛泽东思想、邓小平理论 </option>
<option value= "2 "> 社会科学 </option>
<option value= "3 "> 自然科学 </option>
<option value= "4 "> 法律、哲学 </option>
</select>
</span> </td>
</tr>
<tr>
<td> <span class= "style6 "> 2.出版时间 </span> </td>
<td> <input name= "starttime " type= "text " id= "starttime ">
<span class= "style7 ">
年-- </span>
<input name= "endtime " type= "text " id= "endtime ">
<span class= "style7 "> 年 (可不填) </span> </td>
</tr>
<tr>
<td class= "style6 "> 3.每页显示条数 </td>
<td> <span class= "style7 "> <select name= "rcperpage " class= "style7 " id= "rcperpage ">


<option value= "5 "> 5 </option>
<option value= "10 "> 10 </option>
<option value= "15 "> 15 </option>
</select>
条 </span> </td>
</tr>
<tr>
<td height= "21 "> &nbsp; </td>
<td> &nbsp; </td>
</tr>
<tr align= "center ">
<td height= "42 " colspan= "2 "> <input type= "submit " name= "submit " value= "查询 " > &nbsp;&nbsp;&nbsp;
<input type= "reset " name= "reset " value= "重填 "> </td>
</tr>
</table>
</form>
</body>
</html>
[解决办法]
不会的啊,
没有问题的啊

热点排行
Bad Request.