首页 > 其他 > 详细

二级联动

时间:2018-05-21 10:17:12      阅读:213      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!-- 引入jquery开发包 -->
<script type="text/javascript" src="../libs/jquery-1.11.0.min.js"></script>
<meta http-equiv="content-type" content="textml; charset=UTF-8">
<script type="text/javascript">
//页面加载完成
$(function(){
$("#addBtn").click(function(){

var num =0;

num=num+1;
var name = $("#name").val();
var types = $("#types").val();
var prices = $("#prices").val();
var nums = $("#nums").val();

//在这里边进行判断的操作

if(name==null || name=="" || prices<0 || prices==null || prices==""){
alert("用户名和价钱不能小于0");
}else{
var tr = $("<tr><td>"+num+"</td><td>"+name+"</td><td>"+prices+"</td><td>"+nums+"</td><td>"+types+"</td><td>"+prices+"</td><td><button onclick=‘clikc1(this)‘>删除</button></td></tr>");
$("table").append(tr);
}


});

});


function clikc1(a){

alert("确定要删除商品吗")
$(a).parent().parent().remove();
}
//var tr = $("<tr><td>"+name+"</td><td>"+email+"</td><td>"+phone+"</td><td><a href=‘#‘ onclick=‘deleteItem(this);‘>删除</a></td></tr>");

</script>
</head>

<body>
<div>
<form>
商品名称 <input type="text" name="name" id="name"/>
类型<input type="text" name="types" id="types"/>
价格 <input type="number" name="prices" id="prices"/>
数量 <input type="text" name="nums" id="nums"/>
<input type="button" value="添加" id="addBtn" /><br><!--[if IE]>

<![endif]-->
</form>
<hr/>
<table border="1">
<tr>
<th>商品序号</th>
<th>商品名称</th>
<th>商品价格</th>
<th>商品数量</th>

<th>商品类别</th>
<th>小计</th>
<th>操作</th>
</tr>

</table>


<h3>总价钱:</h3>
</div>
</body>
<ml>

二级联动

原文:https://www.cnblogs.com/xiaxinxin/p/9065562.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!