duan_88598 2017-09-14 21:50
浏览 31
已采纳

复选框正在检查两个复选框

I finished working on my markup today and I started working on code. So here we go here is my markup code.

<form action="" id='createchar'>
        <div id="wrapper">

            <!-- Main -->
                <section id="main">
                    <header>
                        <h1>Create New Character</h1>
                        <input type="text" style="margin-top: 10px; width: 1000px;" name="username" placeholder="პერსონაჟის სახელი"/>
                        <input type="checkbox" value="1" id="checkboxFourInput" name="male"/>
                        <label for="checkboxFourInput" style="margin-left: 9px;">კაცი</label>
                        <input type="checkbox" value="2" id="checkboxFourInput2" name="female"/>
                        <label for="checkboxFourInput2" style="margin-right: 810px;margin-top: 15px;">ქალი</label>
                        <input type="text" style="margin-top: 10px; width: 1000px;" name="explainmg" placeholder="განმარტეთ METAGAMING-ი"/>
                        <input type="text" style="margin-top: 10px; width: 1000px;" name="explainpg" placeholder="განმარტეთ POWERGAMING-ი"/>
                        <textarea rows="10" cols="10" name="charbio" placeholder="დაწერეთ თქვენი პერსონაჟის ბიოგრაფი" style="margin-top: 10px; width: 1000px;"></textarea>
                    </header>
                </section>

            <!-- Footer -->
                <footer id="footer">
                    <ul class="copyright">
                        <li>&copy; <a href="http://ls-rp.ge">LS-RP.GE</a></li><li>Design</li>
                    </ul>
                </footer>

        </div>
    </form>

I have this issue. Both of checkboxes are getting checked but i want to avoid it. how can i make it?

  • 写回答

1条回答 默认 最新

  • duanpi7578 2017-09-14 21:51
    关注

    Basically you should use a radio for that:

    <form action="" id='createchar'>
            <div id="wrapper">
    
                <!-- Main -->
                    <section id="main">
                        <header>
                            <h1>Create New Character</h1>
                            <input type="text" style="margin-top: 10px; width: 1000px;" name="username" placeholder="პერსონაჟის სახელი"/>
                            <input type="radio" value="1" id="checkboxFourInput" name="gender" value="male" />
                            <label for="checkboxFourInput" style="margin-left: 9px;">კაცი</label>
                            <input type="radio" value="2" id="checkboxFourInput2" name="gender" value="female"/>
                            <label for="checkboxFourInput2" style="margin-right: 810px;margin-top: 15px;">ქალი</label>
                            <input type="text" style="margin-top: 10px; width: 1000px;" name="explainmg" placeholder="განმარტეთ METAGAMING-ი"/>
                            <input type="text" style="margin-top: 10px; width: 1000px;" name="explainpg" placeholder="განმარტეთ POWERGAMING-ი"/>
                            <textarea rows="10" cols="10" name="charbio" placeholder="დაწერეთ თქვენი პერსონაჟის ბიოგრაფი" style="margin-top: 10px; width: 1000px;"></textarea>
                        </header>
                    </section>
    
                <!-- Footer -->
                    <footer id="footer">
                        <ul class="copyright">
                            <li>&copy; <a href="http://ls-rp.ge">LS-RP.GE</a></li><li>Design</li>
                        </ul>
                    </footer>
    
            </div>
        </form>

    Note that when use radio you should have all relevant elements have the same value in the name attribute.

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 怎样才能让鼠标沿着线条的中心线轨迹移动
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?