<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<BODY>
<SELECT id="demo_select" NAME="">
</SELECT>
</BODY>
<SCRIPT LANGUAGE="JavaScript">
var select = document.getElementById("demo_select")
for(var i=1i<=30i++){
var opt = document.createElement("option")
opt.value=i
opt.innerHTML=i
select.appendChild(opt)
}
</SCRIPT>
</HTML>
<!DOCTYPE HTML><html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script>
window.onload=function ()
{
var oBtn=document.getElementById('btn')
var oTxt=document.getElementById('txt')
oBtn.onclick=function ()
{
var re=/^\d+$/g
if(re.test(oTxt.value))
{
window.open('http://mt.luansq.com/x/rosi/'+(parseInt(oTxt.value)+1)+'.html')
}
else
{
alert('您输入的内容不正确')
}
}
}
</script>
</head>
<body>
<input type="text" id="txt"><input type="button" value="搜索" id="btn">
</body>
</html>
这是你要的代码,望采纳!
用javascript取值,下面是一个例子:<select id="Select1" onchange="getSelectValue(this)">
<option value="1">第一项</option>
<option selected value="2">第二项(默认选中)</option>
<option value="3">第三项</option>
<option value="4">第四项</option>
</select>
<br /><br /><br />您选择的是:
<span id="selectValue"></span>
<script language="javascript" type="text/javascript">
function getSelectValue(obj) {
var sValue = obj.options[obj.options.selectedIndex].value//这是取值
var sText = obj.options[obj.options.selectedIndex].innerHTML//这是取文本内容
document.getElementById("selectValue").innerHTML = sText + ",他的值为:" + sValue//测试输出
}
</script>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)