如何将三个下拉框中选中的值自动填充到文本框内?详见代码 20
<!DOCTYPEhtml><html><head><metacharset="utf-8"><title></title></script><body>PM设备:<se...
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</script>
<body>
PM设备:
<select style="width: 100px;" id="pre" onchange="chg(this);">
<option value="-1">请选择</option>
</select>
PM类型:
<select style="width: 100px;" id="city" onchange="chg2(this)" ;></select>
PM项目:
<select style="width: 100px;" id="area"></select>
</body>
<script>
var pres = ["设备1", "设备2", "设备3"];
var cities = [
["月度PM", "季度PM", "年度PM"],
["月度PM", "季度PM", "年度PM"],
["月度PM", "季度PM", "年度PM"]
];
var areas = [
[
["1-项目1"],
["1-项目2"],
["1-项目3"]
],
[
["2-项目1"],
["2-项目2"],
["2-项目3"]
],
[
["3-项目1"],
["3-项目2"],
["3-项目3"]
]
]
var pIndex = -1;
var preEle = document.getElementById("pre");
var cityEle = document.getElementById("city");
var areaEle = document.getElementById("area");
for (var i = 0; i < pres.length; i++) {
//声明option.<option value="pres[i]">Pres[i]</option>
var op = new Option(pres[i], i);
preEle.options.add(op);
}
function chg(obj) {
if (obj.value == -1) {
cityEle.options.length = 0;
areaEle.options.length = 0;
}
var val = obj.value;
pIndex = obj.value;
var cs = cities[val];
var as = areas[val][0];
cityEle.options.length = 0;
areaEle.options.length = 0;
for (var i = 0; i < cs.length; i++) {
var op = new Option(cs[i], i);
cityEle.options.add(op);
}
for (var i = 0; i < as.length; i++) {
var op = new Option(as[i], i);
areaEle.options.add(op);
}
}
function chg2(obj) {
var val = obj.selectedIndex;
var as = areas[pIndex][val];
areaEle.options.length = 0;
for (var i = 0; i < as.length; i++) {
var op = new Option(as[i], i);
areaEle.options.add(op);
}
}
</script>
function messageReveal() {
var messageindex = document.messageForm.messagePick.selectedIndex
document.messageForm.messageField.value = messages[messageindex];
}
</script>
<input type="text" id="t1" name="t1" value="">
</head>
</html>
我要实现三个联动下拉框选中相关内容后将选中的文本合并后填充进下面的文本框。 展开
<html>
<head>
<meta charset="utf-8">
<title></title>
</script>
<body>
PM设备:
<select style="width: 100px;" id="pre" onchange="chg(this);">
<option value="-1">请选择</option>
</select>
PM类型:
<select style="width: 100px;" id="city" onchange="chg2(this)" ;></select>
PM项目:
<select style="width: 100px;" id="area"></select>
</body>
<script>
var pres = ["设备1", "设备2", "设备3"];
var cities = [
["月度PM", "季度PM", "年度PM"],
["月度PM", "季度PM", "年度PM"],
["月度PM", "季度PM", "年度PM"]
];
var areas = [
[
["1-项目1"],
["1-项目2"],
["1-项目3"]
],
[
["2-项目1"],
["2-项目2"],
["2-项目3"]
],
[
["3-项目1"],
["3-项目2"],
["3-项目3"]
]
]
var pIndex = -1;
var preEle = document.getElementById("pre");
var cityEle = document.getElementById("city");
var areaEle = document.getElementById("area");
for (var i = 0; i < pres.length; i++) {
//声明option.<option value="pres[i]">Pres[i]</option>
var op = new Option(pres[i], i);
preEle.options.add(op);
}
function chg(obj) {
if (obj.value == -1) {
cityEle.options.length = 0;
areaEle.options.length = 0;
}
var val = obj.value;
pIndex = obj.value;
var cs = cities[val];
var as = areas[val][0];
cityEle.options.length = 0;
areaEle.options.length = 0;
for (var i = 0; i < cs.length; i++) {
var op = new Option(cs[i], i);
cityEle.options.add(op);
}
for (var i = 0; i < as.length; i++) {
var op = new Option(as[i], i);
areaEle.options.add(op);
}
}
function chg2(obj) {
var val = obj.selectedIndex;
var as = areas[pIndex][val];
areaEle.options.length = 0;
for (var i = 0; i < as.length; i++) {
var op = new Option(as[i], i);
areaEle.options.add(op);
}
}
</script>
function messageReveal() {
var messageindex = document.messageForm.messagePick.selectedIndex
document.messageForm.messageField.value = messages[messageindex];
}
</script>
<input type="text" id="t1" name="t1" value="">
</head>
</html>
我要实现三个联动下拉框选中相关内容后将选中的文本合并后填充进下面的文本框。 展开
展开全部
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<body>
PM设备:
<select style="width: 100px;" id="pre" onchange="chg(this);">
<option value="-1">请选择</option>
</select>
PM类型:
<select style="width: 100px;" id="city" onchange="chg2(this)" ;></select>
PM项目:
<select style="width: 100px;" id="area"></select>
</body>
<script>
var pres = ["设备1", "设备2", "设备3"];
var cities = [
["月度PM", "季度PM", "年度PM"],
["月度PM", "季度PM", "年度PM"],
["月度PM", "季度PM", "年度PM"]
];
var areas = [
[
["1-项目1"],
["1-项目2"],
["1-项目3"]
],
[
["2-项目1"],
["2-项目2"],
["2-项目3"]
],
[
["3-项目1"],
["3-项目2"],
["3-项目3"]
]
]
var pIndex = -1;
var preEle = document.getElementById("pre");
var cityEle = document.getElementById("city");
var areaEle = document.getElementById("area");
for (var i = 0; i < pres.length; i++) {
//声明option.<option value="pres[i]">Pres[i]</option>
var op = new Option(pres[i], i);
preEle.options.add(op);
}
function chg(obj) {
if (obj.value == -1) {
cityEle.options.length = 0;
areaEle.options.length = 0;
}
var val = obj.value;
pIndex = obj.value;
var cs = cities[val];
var as = areas[val][0];
cityEle.options.length = 0;
areaEle.options.length = 0;
for (var i = 0; i < cs.length; i++) {
var op = new Option(cs[i], i);
cityEle.options.add(op);
}
for (var i = 0; i < as.length; i++) {
var op = new Option(as[i], i);
areaEle.options.add(op);
}
// alert( preEle.options[preEle.selectedIndex].text)
document.getElementById("t1").value= preEle.options[preEle.selectedIndex].text+ cityEle.options[cityEle.selectedIndex].text+ areaEle.options[areaEle.selectedIndex].text;
}
function chg2(obj) {
var val = obj.selectedIndex;
var as = areas[pIndex][val];
areaEle.options.length = 0;
for (var i = 0; i < as.length; i++) {
var op = new Option(as[i], i);
areaEle.options.add(op);
}
}
function messageReveal() {
var messageindex = document.messageForm.messagePick.selectedIndex
document.messageForm.messageField.value = messages[messageindex];
}
</script>
<input type="text" id="t1" name="t1" value="">
</head>
</html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<body>
PM设备:
<select style="width: 100px;" id="pre" onchange="chg(this);">
<option value="-1">请选择</option>
</select>
PM类型:
<select style="width: 100px;" id="city" onchange="chg2(this)" ;></select>
PM项目:
<select style="width: 100px;" id="area"></select>
</body>
<script>
var pres = ["设备1", "设备2", "设备3"];
var cities = [
["月度PM", "季度PM", "年度PM"],
["月度PM", "季度PM", "年度PM"],
["月度PM", "季度PM", "年度PM"]
];
var areas = [
[
["1-项目1"],
["1-项目2"],
["1-项目3"]
],
[
["2-项目1"],
["2-项目2"],
["2-项目3"]
],
[
["3-项目1"],
["3-项目2"],
["3-项目3"]
]
]
var pIndex = -1;
var preEle = document.getElementById("pre");
var cityEle = document.getElementById("city");
var areaEle = document.getElementById("area");
for (var i = 0; i < pres.length; i++) {
//声明option.<option value="pres[i]">Pres[i]</option>
var op = new Option(pres[i], i);
preEle.options.add(op);
}
function chg(obj) {
if (obj.value == -1) {
cityEle.options.length = 0;
areaEle.options.length = 0;
}
var val = obj.value;
pIndex = obj.value;
var cs = cities[val];
var as = areas[val][0];
cityEle.options.length = 0;
areaEle.options.length = 0;
for (var i = 0; i < cs.length; i++) {
var op = new Option(cs[i], i);
cityEle.options.add(op);
}
for (var i = 0; i < as.length; i++) {
var op = new Option(as[i], i);
areaEle.options.add(op);
}
// alert( preEle.options[preEle.selectedIndex].text)
document.getElementById("t1").value= preEle.options[preEle.selectedIndex].text+ cityEle.options[cityEle.selectedIndex].text+ areaEle.options[areaEle.selectedIndex].text;
}
function chg2(obj) {
var val = obj.selectedIndex;
var as = areas[pIndex][val];
areaEle.options.length = 0;
for (var i = 0; i < as.length; i++) {
var op = new Option(as[i], i);
areaEle.options.add(op);
}
}
function messageReveal() {
var messageindex = document.messageForm.messagePick.selectedIndex
document.messageForm.messageField.value = messages[messageindex];
}
</script>
<input type="text" id="t1" name="t1" value="">
</head>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询