I want to remove HTML field according to Yes/No condition. Currently, all code that I am using I have submitted below to make understand better.
I want when I select Yes it will remove No Field/Input/Box & if I select No it will remove Yes Field/Input/Box.
function AutoCheck() {
if (document.getElementById('yesCheck').checked) {
document.getElementById('ifYes').style.visibility = 'visible';
} else {
document.getElementById('ifYes').style.visibility = 'hidden';
}
if (document.getElementById('noCheck').checked) {
document.getElementById('ifNo').style.visibility = 'visible';
} else {
document.getElementById('ifNo').style.visibility = 'hidden';
}
<div>
<label class="radio">
<label style="float: left; width: 90px;"><input name="auto" id="yesCheck" value="1" type="radio" onclick="javascript:AutoCheck();"> Auto</label>
<label style="float: left; width: 90px;"><input name="auto" id="noCheck" value="0" type="radio" onclick="javascript:AutoCheck();"> Manual</label>
</div>
<div id="ifNo" style="visibility:hidden">
<input id="mcstore_limit" name="mcstore_limit" placeholder="MAX Store Limit" type="number" min="1" step="1">
<div id="ifYes" style="visibility:hidden">
<input id="initial_limit" name="initial_limit" placeholder="MAX Store Limit" type="number" min="1" step="1">
<input id="acstore_limit" name="acstore_limit" placeholder="Initial Store Limit" type="number" min="1" step="1">
<input id="auto_limit" name="auto_limit" placeholder="Auto Increment Limit" type="number" min="1" step="1">
</div>
</div>
Update
I am using Jscripts to remove a field, because there are two field names the same to input data into the database. Here is my HTML code:
<div class="control-group">
<label class="control-label" style="font-family:Verdana, Geneva, sans-serif; font-size:12x; font-weight:bold" for="prefix">Select Storing Mode</label>
<div class="controls">
<label class="radio">
<label style="float: left; width: 90px;">
<input name="auto" id="yesCheck" value="1" type="radio" onclick="javascript:AutoCheck();"> Auto
</label>
<label style="float: left; width: 90px;">
<input name="auto" id="noCheck" value="0" type="radio" onclick="javascript:AutoCheck();"> Manual
</label>
</label>
</div>
</div>
<div class="control-group">
<label class="control-label" style="font-family:Verdana, Geneva, sans-serif; font-size:12x; font-weight:bold" for="cstore_limit">Caller or Callee Store*</label>
<div class="controls">
<div id="ifNo" style="visibility:hidden">
<input style="font-family:Verdana, Geneva, sans-serif; font-size:12x; font-weight:bold" id="cstore_limit" name="cstore_limit" placeholder="MAX Store Limit" type="number" min="1" step="1">
<span class="footnote">Number Only, no space</span>
</div>
<div id="ifYes" style="visibility:hidden">
<input style="font-family:Verdana, Geneva, sans-serif; font-size:12x; font-weight:bold" id="initial_limit" name="initial_limit" placeholder="MAX Store Limit" type="number" min="1" step="1">
<span class="footnote">Number Only, no space</span><br>
<input style="font-family:Verdana, Geneva, sans-serif; font-size:12x; font-weight:bold;margin-top: 5px;" id="cstore_limit" name="cstore_limit" placeholder="Initial Store Limit" type="number" min="1" step="1">
<span class="footnote">Number Only, no space</span><br>
<input style="font-family:Verdana, Geneva, sans-serif;font-size:12x;font-weight:bold;margin-top: 5px;" id="auto_limit" name="auto_limit" placeholder="Auto Increment Limit" type="number" min="1" step="1">
<span class="footnote">Number Only, no space</span><br>
</div>
</div>
</div>
See, there are two fields with the same name & id also cstore_limit to store in DB, but if I use CSS in DB storing value 0 because there is the same field trying to store. Where have I gone wrong?