勾选复选框,然后提交,然后弹出窗口 [英] Tick checkbox then submit and then pop up window

查看:259
本文介绍了勾选复选框,然后提交,然后弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会欣赏,如果有人可以帮助我找到如何解决一个问题,可能我需要非常简单的事情,但我不知道如何把它放在一个,所以我需要 - 包括复选框,然后按钮提交,但如果你不勾选复选框并按下按钮出现窗口,说你必须做....,

I will appreciate if somebody could help me to find how to solve out one problem, probably I need very simple thing but I don't know how to put it in one, so what I need - Section which include tick box, then button submit, but if you don't tick the check box and push the button appear window which says You must do....,

我做了,但我需要这

但如果你打勾和按钮应该顺利出现弹出窗口只有文本信息!我不知道如何得到,
这是带有复选框和按钮的部分

but if you tick and push button should smoothly appear pop up window with just text information! I don't know how to get that, This is thats section with checkbox and button

    <form name="form" method="post" action="#" onSubmit="return checkme();">
    <input type="checkbox" name="agree" value="agree_terms" class="terms">
    &nbsp;I&acute;ve read terms and conditions and I&acute;m ready to shop
    <input type="submit" name="submit" value="" class="submit">
    </form>

这是javascript

and this is javascript

    function checkme() {
        missinginfo = "";
        if (!document.form.agree.checked) {
            missinginfo += "You must agree to the Terms and Conditions";
        }
        if (missinginfo != "") {
            missinginfo ="" +
            "\n" +
            missinginfo + "" +
            "\n Please tick the box and try again.";
            alert(missinginfo);
            return false;
        }
        else {
            return true;
        }
    }

我尝试了不同的方式

    <body>
    <title>LIGHTBOX EXAMPLE</title>
    <style>
    .black_overlay{
    display: none;
    position: absolute;
    top: 0%;
    left: 0%;
    width: 100%;
    height: 100%;
    background-color: black;
    z-index:1001;
    -moz-opacity: 0.8;
    opacity:.80;
    filter: alpha(opacity=80);
    }
    .white_content {
    display: none;
    position: absolute;
    top: 25%;
    left: 25%;
    width: 50%;
    height: 50%;
    padding: 16px;
    border: 16px solid orange;
    background-color: white;
    z-index:1002;
    overflow: auto;
    }
    </style>
    </head>
    <body>


    <p>This is the main content. To display a lightbox click <a href = "javascript:void(0)"
    onclick = "document.getElementById('light').style.display='block';        document.getElementById('fade').style.display='block'">here</a></p>

    <div id="light" class="white_content">This is the lightbox content. <a href =                 "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';                document.getElementById('fade').style.display='none'">Close</a></div>
    <div id="fade" class="black_overlay"></div>
    </body>
    </html>

但是当我勾选复选框的背景出现窗口与内容,但我需要弹出窗口出现只有当我勾选框,并按下按钮

But when I tick check box on the background appear window with the content but I need pop up window appear only after when I tick the box and push the button

推荐答案

你的勾和按钮应平滑出现弹出窗口只是文本信息 - 你几乎做到了。只需添加警报到第二个分支。请尝试此代码:

"f you tick and push button should smoothly appear pop up window with just text information" - you've almost did it. Just add alert to the second branch. Try this code:

<!DOCTYPE html>
<html>
  <!-- [[[ head -->

  <head>
    <title>element</title>
<script type="text/javascript">
  function checkme() {
        if (!document.form.agree.checked) {
            missinginfo = "You must agree to the Terms and Conditions\n Please tick the box and try again.";
            alert(missinginfo);
            return false;
        }
        else {
            alert("Text information");
            return true;
        }
    }
</script>
  </head>
  <!-- ]]] -->

  <body>
    <form name="form" method="post" action="#" onSubmit="return checkme();">
      <input type="checkbox" name="agree" id="agree" value="agree_terms" class="terms">
      <label for="agree">&nbsp;I&acute;ve read terms and conditions and I&acute;m ready to shop</label>
      <input type="submit" name="submit" value="Submit" class="submit">
    </form>
  </body>
</html>

这篇关于勾选复选框,然后提交,然后弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆