我们如何更改按钮以选择选项

时间:2018-11-22 10:31:50

标签: javascript html css

enter image description here我想更改以下代码以选择选项并执行那些功能

<div class="dropdown">
    <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown" id="button1">Date Range
    <span class="caret"  id="car"></span><i class="fa fa-calendar"></i>&nbsp;</select>

    <ul class="dropdown-menu">
        <li><input type="checkbox" class="chb" name="checkfield" id="checkboxes"  onchange="today(this)">Today</li>
        <li><input type="checkbox" class="chb" name="checkfield" id="checkboxes"  onchange="lastweek(this)">Last 7 Days</li>
        <li><input type="checkbox" class="chb" name="checkfield" id="checkboxes"  onchange="last30days(this)">Last 30 Days</li>
        <li><input type="checkbox" class="chb" name="checkfield" id="checkboxes"  onchange="presentmonth(this)">This Month</li>
        <li><input type="checkbox" class="chb" name="checkfield" id="checkboxes"  onchange="lastmonth(this)">Last Month</li>
        <li><input type="checkbox" class="chb" name="checkfield" id="checkboxes"  onchange="yesterday(this)">Yesterday</li>
        <li><input type="checkbox" class="chb" name="checkfield" id="checkboxes"  onchange="today(this)">Custom Range</li>
    </ul>
</div>

Change the second image to the first, the code is for the second image

1 个答案:

答案 0 :(得分:0)

据我所知,您只需要选中一个复选框?

如果是这样,就已经回答了: html select only one checkbox in a group

要对选定的内容执行操作,请添加“ onchange”(就像您已经做过的一样,custome custome复选框遵循today()函数)并进行所需的操作(不要忘记检查复选框的状态(是否选中))< / p>