dongyanju0945 2012-11-04 01:57
浏览 213

如何取消选中该复选框

How to uncheck the checked box if another one is checked.

Could someone help.

Thanks.

<?php

//limit for number of categories displayed per page
$limit = 4;

$categoriesNum= mysql_query("SELECT COUNT('categoryTopic') FROM categories");   

//number of current page
$page =(isset($_GET['page']))? (int) $_GET['page'] :1;

//calculate the current page number 
$begin =($page - 1)* $limit; 

//number of pages needed. 
$pagesCount =ceil(mysql_result ($categoriesNum,0)/$limit);

//Query up all the Categories with setting the Limit 
$CategoryQuery = mysql_query ("SELECT categoryTopic From categories ORDER BY categoryTopic LIMIT $begin, $limit");

//Place all categories in an array then loop through it displaying them one by one
while ($query_rows = mysql_fetch_assoc($CategoryQuery))
{

    $category =$query_rows['categoryTopic'];  
    //echo $category; 
    //query all the subcategories that the current category has 
    $Sub = mysql_query ("SELECT categoryTopic FROM subcategories WHERE categoryTopic='$category'");             
    $Count = mysql_num_rows ($Sub); 

    echo  '<table width="85%" border="1"  cellpadding="0"; cellspacing="0" align="center">

    <tr>        
        <th width="23%" height="44" scope="col" align="left"> '.$query_rows['categoryTopic'].' <br><br><br></th>
        <th width="24%" scope="col">'.$Count.'</th>
        <th width="25%" scope="col"> 0 </th>
        <th width="28%" scope="col"> <form  name = "choose">
        <label><input type="checkbox" id ="check" value= '.$category.' onchange="handleChange(this);"></label>
    </tr>
</table>';  
}
?> 

<script type="text/jscript">
//this funciton will be called when user checks a check box. 

function handleChange(cb) {
//get the selected category 
var category = cb.value;

if another one gets selected I get the value of the new one but two boxes are checked at the same time.

  • 写回答

3条回答 默认 最新

  • douxian1770 2012-11-04 01:59
    关注

    Don't use checkboxes, use radio buttons, and give them all the same name.

    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题