怎样阻止刷新

Z_gainloss 2015-09-19 12:01:39

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('input[name=chooseType]').change(function() {
var val = $(this).val();
if (val == 0)
{
$('#attr_top').children().remove();
var content = '<input id="attrvalue_name1" type="text" name="goodsattrvalue" placeholder="请输入属性值"/>';
var oper=content;
$('#attr_top').append(oper);
}
else if (val == 2||val == 1)
{
var content = '<p><input type="text" name="goodsattrvalue" placeholder="请输入属性值"/><button onClick="attr_add(this)">添加</button></p>';
var oper=content;
alert();
$('#attr_top').append(oper);

}
});
});
function attr_add(obj)
{
if($(obj).prev().val().trim() == '')
{
alert("请输入属性值");
return false;
}
else
{
var content = "<button onclick='attr_del(this)'>删除</button>";
var clone = $(obj).parents('p').clone();
$(clone).find('input').val('');
$(obj).parents('p').after(clone);
$(clone).find('input').focus();
$(obj).parents('p').append(content);
$(obj).remove();
}
}
//删除
function attr_del(obj) {
$(obj).parents('p').remove();
return false;
}
</script>
</head>

<body>
<div id="center" >
<!-- 属性 -->
<form id="attr_fm" method="post">
<div class="easyui-panel" title="添加商品属性">
<!--属性组 到 文本类型-->
<div id="attr_center">
<table border="0" cellpadding="0" cellspacing="0"
style="width: auto; height: auto;">
<tr bgcolor="#FFFFFF" class="row1">
<td width="18%" height="30" align="center">属性名称:</td>
<td width="82%" align="left" colspan="3">
<input id="attr_name" name="name" value="${goodsAttribute.name}" class="span2">
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="4"> </td>
</tr>
<tr>
<td width="20%" height="30" align="center">数据类型:</td>
<td width="20%"><input type="radio" name="dataType" value="1" <c:if test="${goodsAttribute.dataType == 1 }">checked="checked"</c:if>/> 文本</td>
<td width="20%"><input type="radio" name="dataType" value="2" <c:if test="${goodsAttribute.dataType == 2 }">checked="checked"</c:if>/>数字</td>
</tr>
<tr bgcolor="#FFFFFF">
<td colspan="4"> </td>
</tr>
<tr>
<td width="20%" height="30" align="center">文本类型:</td>
<td width="20%"><input type="radio" name="chooseType" value="1" <c:if test="${goodsAttribute.chooseType == 1 }">checked="checked"</c:if> />单选</td>
<td width="20%"><input type="radio" name="chooseType" value="2" <c:if test="${goodsAttribute.chooseType == 2 }">checked="checked"</c:if>/>多选</td>
<td width="20%"><input type="radio" name="chooseType" value="0" <c:if test="${goodsAttribute.chooseType == 0 }">checked="checked"</c:if>/>手动输入</td>
</tr>
</table>
</div>
<!-- 属性值 -->
<div id="attr_top">
<c:forEach items="${goodsAttributeValues}" var="gav">
<tr><td align="center"><p><input type="text" name="goodsattrvalue" value="${gav.goodsattrvalue}"/><button onclick='attr_del(this)'>删除</button></p></td></tr>
</c:forEach>
<tr><td><p><input type="text" name="goodsattrvalue" placeholder="请输入属性值"/><button onClick="attr_add(this)">添加</button></p></td></tr>
</div>
</form>
</div>
<!--保存 取消--->
<!-- <div id="attr_btns">
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="attr_save()">保存</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-no'" onclick="attr_close()">取消</a>
</div> -->
</div>
<br>
</div>
</form>
</body>
</html>
...全文
96 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Z_gainloss 2015-09-19
  • 打赏
  • 举报
回复
就是点击文本类型的单选,出来一个文本框,判断文本框是否为空,若为空则弹出一个框。但是现在的效果是弹出框之后,会自动刷新。怎样阻止刷新
hch126163 2015-09-19
  • 打赏
  • 举报
回复
href="#" =》 href="javascript:;"

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧