gpt4 book ai didi

javascript - 基于单选按钮响应之一启用文本区域

转载 作者:行者123 更新时间:2023-12-02 17:45:45 25 4
gpt4 key购买 nike

我试图根据选择四个单选按钮之一来启用textarea

<div id="Response">
<label><input type="radio" name="Radi4.19" value="Y" id="Radio_4.19_0">Yes</label>
<label><input type="radio" name="Radi4.19" value="N" id="Radio_4.19_1">No</label>
<label><input type="radio" name="Radi4.19" value="NS" id="Radio_4.19_2">Not Seen</label>
<label><input type="radio" name="Radi4.19" value="NA" id="Radio_4.19_3">Not Applicable</label>
</div>

<span id="responseSupplement">
<div id="Comment">
<label for="Comment">Comment:</label>
<textarea name="comment" rows="6" style="width: 530px;" id="Comm4.19" placeholder="Enter comments here ..."></textarea>
</div>

<div id="Observation">`
<label for="Observation">Observation:</label>`
<textarea name="observation" rows="6" disabled="disabled" id="Obs4.19" style="width: 530px;" placeholder="Enter text of observation here ..."></textarea>
</div>
</span>

我能够根据二元选择创建所需的功能:

<script type="text/javascript">

function enable(val)
{if(val)document.f1.feedback.setAttribute("disabled",val)
else
document.f1.feedback.removeAttribute("disabled",val)}
</script>

<form name="f1" action="" >
<input type="radio" name="rating" value="1" id="green" onclick="enable(0)"/><label for="green">Positive</label><br />
<input type="radio" name="rating" value="0" id="red" onclick="enable(1)" /><label for="red">Negative</label><br />
<textarea name="feedback" rows="6" disabled style="width: 50%;" ></textarea>
</form>

最佳答案

您需要读取单击的单选按钮的选中或未选中状态,为此您可以将 this 作为事件监听器的参数传递。

http://jsfiddle.net/m5n6s/

关于javascript - 基于单选按钮响应之一启用文本区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21775168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com