【发布时间】:2016-09-14 07:54:14
【问题描述】:
我有一个动态显示表格行的 PHP sn-p。每一行我都有一个带有“是”和“否”选项的单选按钮。
我创建了一个JS函数,当用户选择一个选项时,会显示一个弹出框。
如果用户在单选按钮中选择“是”选项并在弹出框中单击“确定”,则表格行将被禁用,即使单选按钮也将被禁用。并且选择的选项将保存在 MYSQL 中。
如何在 MySQL 中保存选择的选项?
我的禁用一行的 JS sn-p 不起作用。如何解决这个问题?
PHP:
echo '<td id="resumeFile"><a href="' . $dir . $file . '">Download Resume</a></td>';
echo '<td id="radioOption">
<label for="Yes">Yes</label>
<input type="radio" id="processedOptionYes" name="processedOption" value="Yes" onclick="proccessedCheck()"/>
<label for="No">No</label>
<input type="radio" id="processedOptionNo" name="processedOption" value="No" onclick="proccessedCheck()"/></td>';
JS:
function proccessedCheck(){
var checked = null;
var inputs = document.getElementsByName('processedOption');
for (var i = 0; i < inputs.length; i++){
if (inputs[i].checked) {
checked = inputs[i];
break;
}
}
if(checked == null){
return false;
} else if (checked == true){
document.getElementById("resumeFile").disabled = true;
document.getElementById("radioOption").disabled = true;
document.getElementById("resumeFile").title = "This option has been disabled.";
} else {
return confirm('You have chosen '+ checked.value + ', is this correct?');
}
}
【问题讨论】:
-
我认为您需要禁用表格行中的表单元素。
-
什么意思?如果用户单击该行中的“是”按钮,我需要禁用表格行
-
我假设您希望禁用表格行中的单选按钮。对吗?
-
是的,该表行中的所有数据
标签: javascript php html mysql radio-button