單選按鈕和JS吸。好吧,現在我已經從我的系統中得到了這裏是我的問題:我終於有了Javascript來確認單選按鈕的值後getElementById not playing nice with Radio ButtonsgetElementById,單選按鈕和document.write();
我可以警報的價值,但document.write();將無法工作?
這裏是我的代碼:
<html>
<head>
<script type="text/javascript">
function getRadioValue() {
var y=document.getElementById('draftrequirement_2').value;
document.write(y);
return y;
}
window.onload = function() { alert(getRadioValue()); }
</script>
</head>
<body>
<input onchange="checkRadio()" type="radio" name="draftrequirement" value="na" id="draftrequirement_2" />
</body>
</html>
呼叫*頁面後文件撰寫*加載完成後會導致調用* document.open *,這將**在任何寫作開始之前,清除整個文檔**,包括您的腳本。 – RobG