在一个jsp也没中有如下代码,
<head>
<base href="<%=basePath%>">
<title>My JSP 'showbookinfo.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
<!--
funtion addGoods(goodsid){
window.alert("goodsid");
}
-->
</script> </head>……中间部分省略 <td height="81" colspan="2"><input type="button" name="buy" onclick="addGoods(<%=gb.getGoodsid() %>)" value="购买"></td>我调试的时候,为什么点击购买之后,也没没反应呢?请指点 谢谢哈
<head>
<base href="<%=basePath%>">
<title>My JSP 'showbookinfo.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
<!--
funtion addGoods(goodsid){
window.alert("goodsid");
}
-->
</script> </head>……中间部分省略 <td height="81" colspan="2"><input type="button" name="buy" onclick="addGoods(<%=gb.getGoodsid() %>)" value="购买"></td>我调试的时候,为什么点击购买之后,也没没反应呢?请指点 谢谢哈
2、window.alert("goodsid");中双引号什么作用?应该去掉吧。最简单的办法是f12功能啊,console会报错的,简单的错误一目了然。火狐的firebug是王道。建议还是装上吧,写js必不可少。
建议还是使用Firfox+firebug,写Js真的很有用。
不用不知道,用了你就知道了。
funtion addGoods(goodsid){
window.alert("goodsid");
---------------------------function addGoods(goodsid){
alert(goodsid);
}
这样就行了
window.alert("goodsid");
照样会弹出内容为goodsid,不会是传过来的,其实是语法错误
同上
addGoods(<%=gb.getGoodsid() %)这个地方你确定gb.getGoodsid()不是空值么?
我这样写倒行,<td height="81" colspan="2"><input type="button" name="buy" onclick="window.alert(<%= gb.getGoodsid %>)" value="购买"></td>