亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何根據單擊哪個按鈕在頁面上顯示模式

如何根據單擊哪個按鈕在頁面上顯示模式

幕布斯6054654 2023-05-11 09:49:51
為稍長的代碼道歉。我試圖在頁面上打開模式,但沒有任何反應,我的想法已經用完了?;旧?,如果用戶選擇“訪問課程”按鈕,則帶有 divid01的模式應該以其形式出現。如果點擊“重置訪問代碼”按鈕,它將只顯示與 相關的模態id02。我不確定我在這里做錯了什么。我知道在注釋掉的代碼中,如果我取消注釋并刪除modalFuntion(),那么如果我點擊“重置訪問代碼”按鈕,什么也不會發生,如果我點擊“訪問課程”按鈕,兩種模式都會出現。代碼:   <body>                    <div style="text-align: center; margin-top: 2em;">                <img src="static/images/logo.png">        <h2>INTRODUCTION TO SOFTWARE TESTING ONLINE COURSE</h2>                <!--<button onclick="document.getElementById('id01').style.display='block'" style="width:auto;">Access Course</button>-->        <!--<br/><br/>-->        <!--<button class="buttonLink" onclick="document.getElementById('id02').style.display='block'" style="width:auto;">Forget Access Code</button>-->                <button onclick="modalFunction()" style="width:auto;">Access Course</button>        <br/><br/>        <button class="buttonLink" onclick="modalFunction()" style="width:auto;">Forget Access Code</button>                    </div>        <div id="id01" class="modal">                    <form class="modal-content animate" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">            <div class="imgcontainer">              <span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">&times;</span>            </div>                    <div class="container">              <label for="username"><b>Email</b></label>              <input type="text" placeholder="Enter Email" name="username" required>              <span class="help-block"><?php echo $username_err; ?></span>                <br/><br/>              <label for="password"><b>Access Code</b></label>              <input type="text" placeholder="Enter Access Code" name="password" required>                            <span class="help-block"><?php echo $password_err; ?></span>                              <button type="submit" value="Login" name="Login">Enter</button>          </form>        </div>
查看完整描述

1 回答

?
三國紛爭

TA貢獻1804條經驗 獲得超7個贊

兩個模態內容的結束標簽都被反轉了。


他們都先關閉 theform然后關閉div,但它應該是相反的,而且還有一個</div>缺失(我改進了標識以幫助更好地可視化問題):


<div id="id01" class="modal">

    <form class="modal-content animate" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">

        <div class="imgcontainer">

            <span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">&times;</span>

        </div>

    

        <div class="container">

            <label for="username"><b>Email</b></label>

            <input type="text" placeholder="Enter Email" name="username" required>

            <span class="help-block"><?php echo $username_err; ?></span>

            <br/><br/>

            <label for="password"><b>Access Code</b></label>

            <input type="text" placeholder="Enter Access Code" name="password" required>

            <span class="help-block"><?php echo $password_err; ?></span>    

            <button type="submit" value="Login" name="Login">Enter</button>

        </div>

    </form>

</div>

同樣的事情也適用于id="id02"模態。


查看完整回答
反對 回復 2023-05-11
  • 1 回答
  • 0 關注
  • 129 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號