dtgsl60240 2014-02-06 15:11
浏览 107
已采纳

如何在php的select选项中添加复选框?

I make a php page i want to attach check box with list box option value how i attached checkbox,here is my code:

<select name="recepients[]" multiple size="10" multiple="multiple" >
     <?
        //echo $eventid=$_POST['events'];
        $count=count($_POST['events']);
        for($i=0; $i<$count; $i++){
            $select="select b.first_name,b.last_name from buyers b,registrations r where b.buyer_id=r.buyer_id and r.event_id='".$_POST['events'][$i]."' group by r.buyer_id";
            $res = $GLOBALS ['mysqli']->query ($select) or die ($GLOBALS ['mysqli']->error . __LINE__);
            if ($res->num_rows > 0)
            {           
                while($row = $res->fetch_assoc ())
                {
                ?>
                <input type="checkbox" name="receptionts[]" checked="checked"/> 
                <option value="<?=$row['first_name']?>"><?=$row['last_name']?></option>
                <?
                }
            }
        }
        ?>
 </select>
  • 写回答

2条回答 默认 最新

  • dongzhi5587 2014-03-06 11:24
    关注

    I'm not sure I understand the principle of putting a checkbox in a list.
    If this is to select all default item, you may use the lists multipe with the selected option on the option tags

    <select multiple size="10">
    ...
        <option selected="selected" value="<?=$row['first_name']?>"><?=$row['last_name']?></option>
    ....
    

    good luck :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于c++外部库文件宏的问题,求解
  • ¥15 office打开卡退(新电脑重装office系统后)
  • ¥300 FLUENT 火箭发动机燃烧EDC仿真
  • ¥15 【Hadoop 问题】Hadoop编译所遇问题hadoop-common: make failed with error code 2
  • ¥15 vb6.0+webbrowser无法加载某个网页求解
  • ¥15 RPA财务机器人采购付款流程
  • ¥15 计算机图形多边形及三次样条曲线绘制
  • ¥15 根据protues画的图用keil写程序
  • ¥200 如何使用postGis实现最短领规划?
  • ¥15 pyinstaller打包错误