如何使用复选框按钮在HTML的弹出屏幕中显示结果

时间:2013-10-24 07:53:50

标签: javascript html popup

我想在弹出屏幕中显示复选框按钮选择的结果: 例如,如果我从下面选择:A。空调和e。洗碗机。我想要一个弹出屏幕,上面写着“你选择了空调和洗碗机”,只需点击一下按钮即可显示,然后将其称为“显示”。

       <table name="BuyProduct" id ="BuyProduct_H" style="width:100%;" >

        <tr>                
            <td class="auto-style2" colspan="3">1-&nbsp;&nbsp;&nbsp;&nbsp; What were the products that you bought?          </tr>
        <tr>
            <td class="auto-style53"></td>
            <td colspan="2" class="auto-style54">
                <input id="cbconditioning" type="checkbox"  onclick="Chosen()" />a. Air Conditioning</td>
        </tr>
        <tr>
            <td class="auto-style28">&nbsp;</td>
            <td colspan="2">
                <input id="cbradio" type="checkbox"  onclick="Chosen()"/>b. TV Radio (TV, Home Theatre, etc.)</td>
        </tr>
        <tr>
            <td class="auto-style28">&nbsp;</td>
            <td colspan="2">
                <input id="cbrefrigeration" type="checkbox"  onclick="Chosen()"/>c. Refrigeration</td>
        </tr>
        <tr>
            <td class="auto-style28">&nbsp;</td>
            <td colspan="2">
                <input id="cblaundry" type="checkbox"  onclick="Chosen()"/>d. Laundry (Washer, Dryer, etc)</td>
        </tr>
        <tr>
            <td class="auto-style28">&nbsp;</td>
            <td colspan="2">
                <input id="cbdishwasher" type="checkbox"  onclick="Chosen()" />e. Dishwasher</td>
        </tr>
        <tr>
            <td class="auto-style28">&nbsp;</td>
            <td colspan="2">
                <input id="cbtreatment" type="checkbox"  onclick="Chosen()"/>f. Water Treatment (Water Dispencer)</td>
        </tr>
        <tr>
            <td class="auto-style57"></td>
            <td colspan="2" class="auto-style58">
                <input id="cbhousewares" type="checkbox"  onclick="Chosen()"/>g. Small Housewares (Microwave, Kitchen appliances, etc.)<br />
            </td>
        </tr>
        <tr>
            <td class="auto-style59"></td>
            <td colspan="2" class="auto-style60">
                <input id="cbothers" type="checkbox"  onclick="Chosen()"/>h. Others Please Specify</td>
        </tr>
        <tr>
            <td class="auto-style28">&nbsp;</td>
            <td class="auto-style51"></td>
            <td>
    <asp:TextBox ID="TextBox26" runat="server"></asp:TextBox>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="auto-style28">&nbsp;</td>
            <td colspan="2">
                &nbsp;</td>
        </tr>
        <input type="button" id="chosenlaunch" onclick="Chosen()" value="Equipments Purchased"/>
        </table>

这是我目前使用的脚本,但它显示了多个弹出窗口,而不是包含所有选中结果的弹出窗口:

  function Chosen() {
        if (document.getElementById('cbconditioning').checked == true) {
            alert("You Chose Air Conditioning");
        }
         if (document.getElementById('cbradio').checked == true) {
            alert("You Chose Radio");
        }
         if (document.getElementById('cbrefrigeration').checked == true) {
            alert("You Chose Refrigeration")
        }
         if (document.getElementById('cblaundry').checked == true) {
            alert("You Chose Laundry")
        }
         if (document.getElementById('cbdishwasher').checked == true) {
            alert("You Chose Dishwasher")
        }
         if (document.getElementById('cbtreatment').checked == true) {
            alert("You Chose Treatment")
        }
         if (document.getElementById('cbhousewares').checked == true) {
            alert("You Chose Housewares")
        }
         if (document.getElementById('cbothers').checked == true) {
            alert("You Chose Others")
        }

    }

1 个答案:

答案 0 :(得分:0)

你可以使用jquery对话框实现它,有很多方法,我不是在这里给我的代码而是给你链接,试试这个

JQuery dialog