2016-05-13 5 views
1

私はjs/jqueryを初めて使用しています。私はあなたのスクリプトを簡単に編集することができますように願っています。私のスクリプトの基礎は、ユーザーが「はい」を選択した場合、一連のラジオボタンがあることです。完了しました。ただし、[いいえ]をクリックすると、新しい入力ボックスがポップアップされ、詳細情報が要求されます。Javascript入力フィールドは表示されている場合のみ必要ですか?

残念ながら、ユーザーが[はい]をクリックしても依然として非表示になっているときに問題が発生するため、ポップアップ入力ボックスを送信する必要があります。ここで

は、これまでの私のコードです:

function ShowHide(){ 
    if(document.getElementById('spellingN').checked){ 
     document.getElementById("spellingT").style.display = "block"; 
    } else { 
     document.getElementById("spellingT").style.display = "none"; 
} 
} 

<div class="col-md-4"> 
<div class="radio"><b><input id="spellingY" name="spelling" onchange="ShowHide()" required="" type="radio" value="yes" /> Yes</b></div> 

<div class="radio"><b><label for="radios-1"><input id="spellingN" name="spelling" onchange="ShowHide()" required="" type="radio" value="no" /> No </label></b></div> 
</div> 
</div> 

<div id="spellingT" style="display: none;"> 
<div class="form-group"><b><label class="col-md-4 control-label" for="Spelling-Correction"><b>Question 2a</b> Type the grammatically correct version of the term.</label> </b> 

<div class="col-md-4"><b><input class="form-control input-md" id="Grammar-Correction" name="Grammar-Correction" placeholder="" required="" style="width: 100%;" type="text" /></b></div> 
</div> 

私はあなたがそれのいくつかの意味を理解し、私を助けることができるでしょう願っています。前もって感謝します!

答えて

1

あなたはあなたの関数では、このチェックを追加することができます。詳細については

if(document.getElementById('spellingT').style.display == "block"){ 
    //your submission 
} 
0
// Element is hidden 
if(document.getElementById('spellingT').offsetParent === null) 
{ 

} 
// Element is visible 
else 
{ 

} 

は申し訳ありませんが、私はそれを使用する方法について少し困惑しているhttps://stackoverflow.com/a/21696585/2240375

+0

をご覧ください。私はJSで非常に経験がありません。あなたはどんなことを練ることができますか?ありがとうございました。 – Rob

関連する問題