Gmail ckeckbox和按钮

时间:2018-04-24 09:48:27

标签: html button checkbox gmail

是否可以添加一个复选框和一个仅在gmail中选中所有复选框时启用的按钮?

我已经有了这个:

<html>
<body>

<form action="/action_page.php" method="get">
  <input type="checkbox" name="terminos" value="condiciones"> Acepto los terminos y condiciones<br>
  <input type="checkbox" name="politica" value="privacidad" checked> Acepto la política de privacidad<br>
  <input type="checkbox" name="sorteo" value="Car" checked> Acepto las condiciones del sorteo<br>

</form>

</body>
</html>

但我没有按钮,因为我不知道该怎么做。

你能帮助我吗?

(而且,我想要一个带有白色字母的大中心红色按钮,但是现在我只想知道如何制作按钮。如果你能解决这个问题我会非常感激)

2 个答案:

答案 0 :(得分:1)

根据我对您的问题的理解,您需要使用JavaScript来显示/隐藏按钮,具体取决于是否检查了所有按钮。以下是一个示例:

function checkAllClicked() {
    let button = document.getElementById('button');
    if(document.getElementById('box1').checked &&
        document.getElementById('box2').checked &&
        document.getElementById('box3').checked) {
      button.style.display = "block";
    } else {
      button.style.display = "none";
    }
  }

此功能基本上检查是否使用logical AND gate后面的逻辑检查所有按钮(标识为box1box2box3),并切换按钮是否为可见与否。

这是在您的网页上下文中:

&#13;
&#13;
function checkAllClicked() {
  const button = document.getElementById('button');
  // check if check boxes are all selected
  if(document.getElementById('box1').checked &&
      document.getElementById('box2').checked &&
      document.getElementById('box3').checked) {
    // display the submit button
    button.style.display = "block";
  } else {
    // hide the submit button
    button.style.display = "none";
  }
}
&#13;
<!DOCTYPE html>
<html>
<body>
  <form action="/action_page.php" method="get">
    <input type="checkbox" id="box1" name="terminos" value="condiciones" onclick="checkAllClicked()"> Acepto los terminos y condiciones<br>
    <input type="checkbox" id="box2" name="politica" value="privacidad" checked  onclick="checkAllClicked()"> Acepto la política de privacidad<br>
    <input type="checkbox" id="box3" name="sorteo" value="Car" checked  onclick="checkAllClicked()"> Acepto las condiciones del sorteo<br>
    <input type="submit" id="button" value="Submit" style="display: none;">
  </form>
</body>
</html>
&#13;
&#13;
&#13;

显然,/action_page.php必须存在才能使表单执行任何操作,否则代码将查找不存在的.php文件并抛出错误。

答案 1 :(得分:1)

没有

我不知道任何支持HTML格式电子邮件中嵌入JavaScript(或任何其他类型的程序逻辑)的电子邮件客户端。

GMail的网络用户界面肯定不支持。