如何根据单选按钮选择更改可选择的下拉选项。这是我正在使用的代码
HTML:
<div id="manage">
<div>
<label>Operating Systems</label>
<select id="OS" onchange="browserlist();">
<option value="win7 32">Windows 7 - 32</option>
<option value="win7 64">Windows 7 - 64</option>
<option value="Vista 32">Windows Vista - 32</option>
<option value="Vista 64">Windows Vista - 64</option>
<option value="Win8 X64">Windows 8 - X64</option>
</select>
</div>
<div>
<label>Browsers</label>
<select id="browsers" onchange="browserDet();">
<option value="ie">IE</option>
<option value="vista">Vista</option>
</select>
</div>
<div>
<label>Versions</label>
<select id="version"></select>
</div>
<div>
<label>Test Scripts</label>
<select id="testscriptlist">
<option value="1">test1</option>
<option value="2">test2</option>
<option value="3">test3</option>
<option value="4">test34</option>
</select>
</div>
<div>
<label>Server:</label>
<input type="text" id="server" value="" />
</div>
JavaScript:
$.ajax({
type: 'GET',
url: "/getJobs",
dataType: "json",
success: function (jobs) {
//alert(jobs);
if (jobs.length == 0) {
alert("There are no scheduled Jobs");
$("#jobsTable").hide();
} else {
//jobs.forEach(function(job) {
$.each(jobs, function (key, value) {
alert(value.jobid);
var tabString = '<tr><td>' + value._id + '</td><td>' + value.os + '</td><td>' + value.browser + '</td><td>' + value.version + '</td><td>' + value.script + '</td><td>' + value.server + '</td><td>' + '<input type="radio" name="joblist" onclick="myfunc(this);" id= ' + value.jobid + 'value=' + value.jobid + '/> </td></tr>';
$("#jobsTable").append(tabString);
});
}
}
});
}
以下代码在单选按钮的 onclick 中使用。选择单选按钮时,我将获得单选按钮值,并且必须根据单选按钮选择更改可选择的下拉选项。
function myfunc(ele) {
var $tr = $(ele).parent().parent();
var os = $tr.find("td:eq(1)").html();
var browsers = $tr.find("td:eq(2)").html();
var version = $tr.find("td:eq(3)").html();
var testscriptlist = $tr.find("td:eq(4)").html();
var server = $tr.find("td:eq(5)").html();
}