function check() { var inst="爱好:"; if(document.myform.txt1.value=="") { alert("Buddy,请输入姓名!"); } else { alert("姓名:"+document.myform.txt1.value); if(document.myform.sex[0].checked) alert("性别:男"); else alert("性别:女"); if(document.myform.inst[0].checked) inst +="游泳"; if(document.myform.inst[1].checked) inst +=",滑冰"; if(document.myform.inst[2].checked) inst +=",游泳"; if(inst=="爱好:") alert("赶快培养一个爱好吧!"); else alert(inst); } }
回复讨论(解决方案)
这个是书上的源代码,感觉没什么差别啊!都郁闷一天,求高手帮助。
function check() { var inst = "爱好:"; if(document.myform.txt1.value=="") { alert("请输入姓名!"); } else { alert("姓名:"+document.myform.txt1.value ); if(document.myform.sex[0].checked) alert("性别:男"); else alert("性别:女"); if(document.myform.inst[0].checked) inst += "游泳"; if(document.myform.inst[1].checked) inst += ",滑冰"; if(document.myform.inst[2].checked) inst += ",散步"; if(inst=="爱好:") alert("赶快培养一个爱好吧!"); else alert(inst); } }
已解决,通过BCompare软件比较与源代码区别,发现 if(document.myform.sex[0].checked) alert("性别:男");里面左括号是中文括号,以后得细心点了。
/wo y呵呵 就是嘛
查看更多关于请教一下我的jsp代码错哪了,alert不出来_html/css_WEB-ITnose的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did104228