|
为什么 <script type="text/javascript">
//数据集
var schools = [
{ "value": "南京大学" },
{ 'value': '北京大学' },
{ 'value': '清华大学' },
{ 'value': '浙江大学' },
{ 'value': '同济大学' },
];
var table = [
{ 'value': '122' },
{ 'value': '123' },
];
$(function () {
if (schools.length > 0) {
for (var i = 0; i < schools.length; i++) {
var item = schools[i];
$('#schoolList')
.append('<option value="' + item.value + '"></option>');
}
}
});
function load()
{
var school=document.getElementById('txtTest').value;
if (school == '南京大学') {
$(function () {
if (table.length > 0) {
for (var i = 0; i < table.length; i++) {
var item = table[i];
$('#testList')
.append('<option value="' + item.value + '"></option>');
}
}
});
}
}
</script>能取到value的值,er <script type="text/javascript">
function autotext() {
var keywords = document.getElementById("keywords").value;
$(function () {
if (keyword.length > 0) {
for (var i = 0; i < keyword.length; i++) {
var item = keyword[i];
alert(item);
$('#placetext')
.append('<option value="' + item.name + '"></option>');
}
}
});
}
var keyword = [{ "name": "安徽省", "adcode": "34000o" },
{ "name": "福建省", "adcode": "35000o" },
{ "name": "甘肃省", "adcode": "620000" },
{ "name": "广东省", "adcode": "440000" },
{ "name": "广西壮族自差区", "adcode": "45000o" },
{ "name": "贵州省", "adcode": "52000o" }];
</script>
</head>
<body>
<form>
<datalist id="placetext"></datalist>
<input type="text" placeholder="搜索" id="keywords" list="placetext" onblur="autotext()">
</form>
却取不到name的值?
|
-
-
|