我有2個單選按鈕。當單擊第一個單選按鈕文本框將打開,當點擊另一個單選按鈕時第二個文本框將打開..現在我想當我點擊在第二個單選按鈕上,第一個單選按鈕文本框應該清晰。如何通過單擊另一個單選按鈕清除第一個單選按鈕文本框的值
查看:
<label>Assign Credit Limit Amount/Days</label><br>
<label for="chkYes">Credit Amount</label>
<input type="radio" id="chkYes" name="chkPassPort" onclick="ShowHideDiv()"/>
<label for="chkNo">Day</label>
<input type="radio" id="chkNo" name="chkPassPort" onclick="ShowHideDiv()" />
<div id="creditAmount" style="display: none"><br>
<label for="creditAmount">Credit Amount</label>
<input type="text" class="form-control" id="creditAmount" placeholder="creditAmount" name="creditAmount" maxlength="128">
</div>
<div id="day" style="display: none"><br>
<label for="day">Day</label>
<input type="text" class="form-control" id="day" placeholder="day" name="day" maxlength="128">
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
的javascript:
<script type="text/javascript">
function ShowHideDiv() {
var chkYes = document.getElementById("chkYes");
var chkNo = document.getElementById("chkNo");
var creditAmount = document.getElementById("creditAmount");
creditAmount.style.display = chkYes.checked ? "block" : "none";
var day = document.getElementById("day");
day.style.display = chkNo.checked ? "block" : "none";
}
</script>
你能詳細闡述一下你的要求嗎? –
最簡單的解決方案是: document.getElementById(id_of_textbox).value =「」; – Calaris