How to clear input field after radio button click?
P粉396248578
2023-09-02 16:07:22
<p>After clicking "Select number of tweets from date", the "Select end date" input field must be removed. Can anyone help me? This is the code: </p>
<p>
<pre class="brush:js;toolbar:false;">function yesnoCheck() {
if (document.getElementById('yesCheck').checked) {
document.getElementById('ifYes').style.display = 'block';
} else document.getElementById('ifYes').style.display = 'none';
}</pre>
<pre class="brush:html;toolbar:false;"><form>
<input type="radio" onclick="javascript:yesnoCheck();" name="yesno" id="noCheck">Select date range <br>
<br>
<input type="radio" onclick="javascript:yesnoCheck();" name="yesno" id="yesCheck">Select number of tweets from date<br><br>
<div id="ifYes" style="display:none">
Desired number of tweets <input type="number" min="1" max="20" id='yes' name='yes'><br>
</div>
<br>
<img src="icon2.png"><label for="date">Select start date:</label><br>
<input type="datetime-local" id="Test_DatetimeLocal"><br><br>
<img src="icon2.png"><label for="date">Select end date:</label><br>
<input type="datetime-local" id="Test_DatetimeLocal"><br><br>
<input type="submit" value="submit" class="submit">
</form></pre>
</p>
Follow your
#ifYes
tags. Wrap the input and label withdiv
, assign it anid
, and then just usedocument.getElementById('select-end-period').style.display = 'none';