[英]Struts setting radio button value from javascript
我有一個Struts單選按鈕,試圖從JavaScript設置,但沒有成功。
以下是我嘗試過的代碼和選項。
單選按鈕
<s:radio name = "myrdb"
id = "myrdb"
list = "#{'true':'Yes','false':'No'}"
onclick = "rdbFunction(this.value)" />
選項嘗試:
document.getElementById('myrdb').value = 'true';
document.getElementById('myrdb').attr('value', 'true');
document.getElementById('myrdb').set('value', 'true');
代碼對我來說似乎可以,並且如果沒有其他(不好的)事情發生,這應該可以工作。 沒有輸出也沒有錯誤,我只能向您推薦:
在純JavaScript中:
document.getElementById("myrdb").checked = true;
在jQuery中
$("#myrdb").prop('checked', true);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.