按条件提交按钮浮动功能

时间:2016-10-12 09:37:42

标签: javascript forms conditional-statements submit-button

我有一个表格听起来像这样:如果客户选择YES,则会出现另一个表格,如果选择NO,他可以提交表格。 但如果他选择NO,则SUBMIT按钮会保持不动,这可能会有点棘手。 所以,问题是,当选择“否”答案时,我必须采用什么条件使提交按钮更接近?

以下是html代码的部分条件:

<div id="ifYes" style="visibility:hidden">
    <div class="col-md-12 padding-top-10">
      <h1 span style="color:red">If you need visa, please complete the following data:</h1></br>        
    </div>
    <label for="firstName" class="control-label">Full name(as written in the passaport):</label>
    <div class="form-group">
        <div class="col-md-6 padding-top-10">
            <input type="text" class="form-control" required data-parsley-pattern="^[a-zA-Z ]+$" data-parsley-trigger="keyup" id="firstName" placeholder="First"  />
        </div>
        <div class="col-md-6 padding-top-10">
            <input type="text" class="form-control" required data-parsley-pattern="^[a-zA-Z ]+$" data-parsley-trigger="keyup" id="lastName" placeholder="Last"/>
         </div>
    </div>

 

这是JS函数:

function yesnoCheck() {
     if (document.getElementById('yesCheck').checked) {
         document.getElementById('ifYes').style.visibility = 'visible';
     } else  {
         document.getElementById('ifYes').style.visibility = 'hidden';
     }
 }

1 个答案:

答案 0 :(得分:1)

使用display来显示/隐藏“表单”

What is the difference between visibility:hidden and display:none?

RewriteEngine On
RewriteBase /beta

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
function yesnoCheck() {
  if (document.getElementById('yesCheck').checked) {
    document.getElementById('ifYes').style.display = 'block';
  } else {
    document.getElementById('ifYes').style.display = 'none';
  }
}
form {
  border: solid 1px black;
}