Asp.net页面中javascript不起作用
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "SignUpTwo.aspx.cs " Inherits= "Profile_SignUpTwo " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div class= "Input "> <select id= "bYear " name= "bYear "> </select> <!--
--> <select id= "bDay " name= "bDay "> </select> <!--
-->
<select id= "bMonth " name= "bMonth "> </select> <!--
-->
<script type= "text/javascript ">
function selMosb(pid,pval){
var h=document.getElementById(pid);
var m= new Array( '一月 ', '二月 ', '三月 ', '四月 ', '五月 ', '六月 ', '七月 ', '八月 ', '九月 ', '十月 ', '十一月 ', '十二月 ');
for(var i=1; i <= 12;i++)
h.options[h.options.length]=new Option(m[i-1],i);
h.value=pval;
}
function selRngb(pid,pval,pstart,pend){
var h=document.getElementById(pid);
if (pend <pstart) {
for(var i=pstart; i> =pend; i--)
h.options[h.options.length]=new Option(i,i);
}
else
{
for(var i=pstart;i <=pend; i++)
h.options[h.options.length]=new Option(i,i);
}
h.value=pval;
}// addStuff
function selAddBlnkb(pid,pidx){
var l= new Array( '年 ', '月 ', '日 ');
var h=document.getElementById(pid);
h.options[h.options.length]=new Option(l[pidx],0);
}
selAddBlnkb( "bYear ",0);
selAddBlnkb( "bMonth ",1 );
selAddBlnkb( "bDay ",2);
selMosb( "bMonth ", 0 );
selRngb( "bDay ", 0, 1, 31 );
selRngb( "bYear ", 0, 2007, 1907 );
</script>
</div>
</form>
</body>
</html>
[解决办法]
刚才试了下 没问题啊
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "testjs.aspx.cs " Inherits= "testjs " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head id= "Head1 " runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div class= "Input "> <select id= "bYear " name= "bYear "> </select> <!--
--> <select id= "bDay " name= "bDay "> </select> <!--
-->
<select id= "bMonth " name= "bMonth "> </select> <!--
-->
<script type= "text/javascript ">
function selMosb(pid,pval){
var h=document.getElementById(pid);
var m= new Array( '一月 ', '二月 ', '三月 ', '四月 ', '五月 ', '六月 ', '七月 ', '八月 ', '九月 ', '十月 ', '十一月 ', '十二月 ');
for(var i=1; i <= 12;i++)
h.options[h.options.length]=new Option(m[i-1],i);
h.value=pval;
}
function selRngb(pid,pval,pstart,pend){
var h=document.getElementById(pid);
if (pend <pstart) {
for(var i=pstart; i> =pend; i--)
h.options[h.options.length]=new Option(i,i);
}
else
{
for(var i=pstart;i <=pend; i++)
h.options[h.options.length]=new Option(i,i);
}
h.value=pval;
}// addStuff
function selAddBlnkb(pid,pidx){
var l= new Array( '年 ', '月 ', '日 ');
var h=document.getElementById(pid);
h.options[h.options.length]=new Option(l[pidx],0);
}
selAddBlnkb( "bYear ",0);
selAddBlnkb( "bMonth ",1 );
selAddBlnkb( "bDay ",2);
selMosb( "bMonth ", 0 );
selRngb( "bDay ", 0, 1, 31 );
selRngb( "bYear ", 0, 2007, 1907 );
</script>
</div>
</form>
</body>
</html>
[解决办法]
有值的呀?
妳再試試,我直接吧妳的代碼放在文本框中的,保存成html後就有值的
[解决办法]
试了一下没有问题,看代码也没错
[解决办法]
实际上js执行的结果一闪就消失了
在return false;前加入event.cancelBubble = true;
[解决办法]
JS放在你那处理的东西的前边~ 离开一点