<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>测试js</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<script type="text/javascript" language="javascript">...
var selIndex;
function indx()...{
selIndex=document.getElementById('list1').options.selectedIndex;
}
function chk(val)...{
var selIndex2=document.getElementById('list1').selectedIndex;
if(confirm('你真的要选择'+val))...{
document.getElementById('list1').options[selIndex2].selected='selected';
selIndex=selIndex2;
return true;
}else...{
document.getElementById('list1').options[selIndex].selected='selected';
}
}
</script>
</head>
<body onLoad="indx()">

<form method="get" >
<select size="1" name="list1" id="list1" onChange="chk(this.options[this.options.selectedIndex].text)">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</form> 
</body>
</html>
本文展示了一个简单的HTML页面如何使用JavaScript进行交互控制。通过一个下拉菜单的选择变化触发JavaScript函数,实现对用户选择确认的功能,并保持用户的选择状态。
191

被折叠的 条评论
为什么被折叠?



