62,266
社区成员
发帖
与我相关
我的任务
分享<table>
<tr><td>
<asp:Button runat="server" ID="Add" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" ID="num" Height="25px" style="margin-top: 0px" Width="73px" >0
</asp:TextBox> <asp:Button runat="server" ID="reduce" Text="-" Height="34px" Width="38px"/>
<asp:Button runat="server" ID="delete" Text="清空" Height="33px" Width="61px" />
</td></tr>
</table> $('#<%=Add.ClientID%>').click(function () {
var q = parseInt($('#<%=num.ClientID%>').val());
$('#<%=num.ClientID%>').val(q + 1);
});
$('#<%=reduce.ClientID%>').click(function () {
var q = parseInt($('#<%=num.ClientID%>').val());
if (q > 0)
$('#<%=num.ClientID%>').val(q - 1);
});
$('#<%=delete.ClientID%>').click(function () {
var q = parseInt($('#<%=num.ClientID%>').val());
if (q > 0)
$('#<%=num.ClientID%>').val(q * 0);
});<table>
<tr><td>
<asp:Button runat="server" ID="Add" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" ID="num" Height="25px" style="margin-top: 0px" Width="73px" >0
</asp:TextBox> <asp:Button runat="server" ID="reduce" Text="-" Height="34px" Width="38px"/>
<asp:Button runat="server" ID="delete" Text="清空" Height="33px" Width="61px" />
</td></tr>
</table>
</div>
<br />
<div>
</div>
<%--<table>
<tr><td> <asp:Button runat="server" ID="reduce1" Text="-" Height="34px" Width="38px"/>
<asp:TextBox runat="server" ID="total1" Height="25px" style="margin-top: 0px" Width="73px" >0 </asp:TextBox>
<asp:Button runat="server" ID="Add1" Text="+" Height="33px" Width="52px" />
<asp:Button runat="server" ID="delete1" Text="清空" Height="33px" Width="61px" />
</td></tr>
</table>--%>
</div>
</form>
</body>
<script src="../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('table tr td').on('click', '.add', function () {
var value = parseInt($(this).next(':first').val());
$(this).next(':first').val(value + 1);
})
$('table tr td').on('click', '.remove', function () {
var value = parseInt($(this).prev(':first').val());
$(this).prev(':first').val(value - 1);
})
$('table tr td').on('click', '.clear', function () {
$(this).siblings('.show').val(0);
})
})
$('#<%=Add.ClientID%>').click(function () {
var q = parseInt($('#<%=tax1.ClientID%>').val());
$('#<%=tax1.ClientID%>').val(q + 1);
});
$('#<%=reduce.ClientID%>').click(function () {
var q = parseInt($('#<%=tax1.ClientID%>').val());
if (q > 0)
$('#<%=tax1.ClientID%>').val(q - 1);
});
$('#<%=delete.ClientID%>').click(function () {
var q = parseInt($('#<%=tax1.ClientID%>').val());
if (q > 0)
$('#<%=tax1.ClientID%>').val(q * 0);
});
</script>
</html>
<table style="float:left;margin-left:5px;margin-top:15px" >
<tr><td></td><td align="right" >平光
<asp:Button runat="server" ID="reduce" Text="-" Height="33px" Width="52px" style="background-color:#1ebeb9"/>
<asp:TextBox runat="server" ID="tax1" Height="25px" style="margin-top: 0px;background-color:#DDCCDD" Width="73px" onchange="Settotal('tax1');" >
</asp:TextBox> <asp:Button runat="server" ID="Add" Text="+" Height="34px" Width="38px" style="background-color:#1ebeb9"/>
<asp:Button runat="server" ID="delete" Text="清空" Height="33px" Width="61px" style="background-color:#1ebeb9"/>
</td></tr>
<tr><td></td><td align="right" bgcolor="#e5e5e5" >-100
<asp:Button runat="server" ID="Button92" Text="-" Height="33px" Width="52px" CssClass="remove" />
<asp:TextBox runat="server" ID="tax2" Height="25px" style="margin-top: 0px" Width="73px" Text="0" CssClass="show" onchange="Settotal('tax2');" >
</asp:TextBox> <asp:Button runat="server" ID="Button93" Text="+" Height="34px" Width="38px" CssClass="add" />
<asp:Button runat="server" ID="Button94" Text="清空" Height="33px" Width="61px" CssClass="clear" />
</td>
</tr> <tr><td colspan="2" align="right">-125
<asp:Button runat="server" ID="Button95" Text="-" Height="33px" Width="52px" />
<asp:TextBox runat="server" ID="tax3" Height="25px" style="margin-top: 0px" Text="0" Width="73px" onchange="Settotal('tax3');" >
</asp:TextBox> <asp:Button runat="server" ID="Button96" Text="+" Height="34px" Width="38px"/>
<asp:Button runat="server" ID="Button97" Text="清空" Height="33px" Width="61px" />
</td></tr> <tr><td></td><td align="right" bgcolor="#e5e5e5">-150
<asp:Button runat="server" ID="Button98" Text="-" Height="33px" Width="52px" />
<asp:TextBox runat="server" ID="tax4" Height="25px" style="margin-top: 0px" Width="73px" onchange="Settotal('tax4');" Text="0" >
</asp:TextBox> <asp:Button runat="server" ID="Button99" Text="+" Height="34px" Width="38px"/>
<asp:Button runat="server" ID="Button100" Text="清空" Height="33px" Width="61px" />
</td></tr> <tr><td></td><td align="right" >-175
<asp:Button runat="server" ID="Button101" Text="-" Height="33px" Width="52px" />
<asp:TextBox runat="server" ID="tax5" Height="25px" style="margin-top: 0px" Width="73px" onchange="Settotal('tax5');" Text="0" >
</asp:TextBox> <asp:Button runat="server" ID="Button102" Text="+" Height="34px" Width="38px"/>
<asp:Button runat="server" ID="Button103" Text="清空" Height="33px" Width="61px" />
</td></tr> <tr><td></td><td align="right" bgcolor="#e5e5e5">-200
<asp:Button runat="server" ID="Button104" Text="-" Height="33px" Width="52px" />
<asp:TextBox runat="server" ID="tax6" Height="25px" style="margin-top: 0px" Width="73px" onchange="Settotal('tax6');" Text="0">
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Order_new2.aspx.cs" Inherits="Employee_Order_new2" %>
<!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" id="Head1">
<title></title>
<link href="../css/GamerGridView.css" rel="stylesheet" type="text/css" />
<link href="../css/calendar.css" rel="stylesheet" type="text/css" />
<link href="../css/modalpopup.css" rel="stylesheet" type="text/css" />
<script src="../Scripts/common.js" language="javascript" type="text/javascript"></script>
<script type="text/javascript" src="../Scripts/jquery-1.4.1.min.js"></script>
<script src="../Scripts/jquery-1.11.2.min.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
function roundNumber(num, dec) {
var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
return result;
}
function Settotal(amt) {
var price = $get(amt).value;
if (IsNumeric(price) == false && price > '')
{
alert('请只输入数字');
$get("" + amt).value = 0;
$get("" + amt).focus;
}
else
{
var total = $get("total").value;
var total1 = $get("total1").value;
var total2 = $get("total2").value;
var taxprice = 0
var makprice = 0
var officeprice = 0
for (i = 1; i <= 29; i++)
{
if ($get("tax" + i).value > 0)
taxprice = taxprice + roundNumber($get("tax" + i).value, 3);
if ($get("mkt" + i).value > 0)
makprice = makprice + roundNumber($get("mkt" + i).value, 3);
if ($get("office" + i).value > 0)
officeprice = officeprice + roundNumber($get("office" + i).value, 3);
}
//var makprice = 0
//for (i = 1; i <= 29; i++) {
// if ($get("mkt" + i).value > 0)
// makprice = makprice + roundNumber($get("mkt" + i).value, 3);
//}
//var officeprice = 0
//for (i = 1; i <= 29; i++) {
// if ($get("office" + i).value > 0)
// officeprice = officeprice + roundNumber($get("office" + i).value, 3);
//}
$get("total").value = roundNumber(parseFloat(taxprice), 3);//+ parseFloat(makprice) + parseFloat(officeprice) + parseFloat(office10_1) + parseFloat(office11_1) + parseFloat(tax10_1) + parseFloat(tax13_1) + parseFloat(tax14_1) + parseFloat(tax15),
$get("total2").value = roundNumber(parseFloat(makprice), 3);
$get("total1").value = roundNumber(parseFloat(officeprice), 3);
}
}
</script>
<style type="text/css">
.auto-style1 {
color: #000000;
}
.auto-style2 {
color: #800000;
font-size: x-large;
background-color: #DDCCDD;
}
</style>
</head>
<body style="background-color:#f5f5f5;width:100%">
<form id="form1" runat="server">
<asp:ScriptManager ID="scriptManager" runat="server" />
<div style="font-size:18px">
<div ><table border="1" bordercolor="#c8cccc" width="100%" style="margin-top:15px">
</table><table>
<tr>
<td>
<asp:Button runat="server" CssClass="add" ID="Add" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" CssClass="show" ID="num" Height="25px" Style="margin-top: 0px" Width="73px">0</asp:TextBox>
<asp:Button runat="server" CssClass="remove" ID="reduce" Text="-" Height="34px" Width="38px" />
<asp:Button runat="server" CssClass="clear" ID="delete" Text="清空" Height="33px" Width="61px" />
</td>
</tr>
<tr>
<td>
<asp:Button runat="server" CssClass="add" ID="Button1" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" CssClass="show" ID="TextBox1" Height="25px" Style="margin-top: 0px" Width="73px">0</asp:TextBox>
<asp:Button runat="server" CssClass="remove" ID="Button2" Text="-" Height="34px" Width="38px" />
<asp:Button runat="server" CssClass="clear" ID="Button3" Text="清空" Height="33px" Width="61px" />
</td>
</tr>
<tr>
<td>
<asp:Button runat="server" CssClass="add" ID="Button4" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" CssClass="show" ID="TextBox2" Height="25px" Style="margin-top: 0px" Width="73px">0</asp:TextBox>
<asp:Button runat="server" CssClass="remove" ID="Button5" Text="-" Height="34px" Width="38px" />
<asp:Button runat="server" CssClass="clear" ID="Button6" Text="清空" Height="33px" Width="61px" />
</td>
</tr>
</table>
[/quote]清空有用 可是加减没有用
[/quote]
我把测试ok的完整代码贴上,你看下
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Demo_Test.test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<title></title>
<style type="text/css">
table td input {
margin: 10px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td>
<asp:Button runat="server" CssClass="add" ID="Add" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" CssClass="show" ID="num" Height="25px" Style="margin-top: 0px" Width="73px">0</asp:TextBox>
<asp:Button runat="server" CssClass="remove" ID="reduce" Text="-" Height="34px" Width="38px" />
<asp:Button runat="server" CssClass="clear" ID="delete" Text="清空" Height="33px" Width="61px" />
</td>
</tr>
<tr>
<td>
<asp:Button runat="server" CssClass="add" ID="Button1" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" CssClass="show" ID="TextBox1" Height="25px" Style="margin-top: 0px" Width="73px">0</asp:TextBox>
<asp:Button runat="server" CssClass="remove" ID="Button2" Text="-" Height="34px" Width="38px" />
<asp:Button runat="server" CssClass="clear" ID="Button3" Text="清空" Height="33px" Width="61px" />
</td>
</tr>
<tr>
<td>
<asp:Button runat="server" CssClass="add" ID="Button4" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" CssClass="show" ID="TextBox2" Height="25px" Style="margin-top: 0px" Width="73px">0</asp:TextBox>
<asp:Button runat="server" CssClass="remove" ID="Button5" Text="-" Height="34px" Width="38px" />
<asp:Button runat="server" CssClass="clear" ID="Button6" Text="清空" Height="33px" Width="61px" />
</td>
</tr>
</table>
</form>
</body>
</html>
<script type="text/javascript">
$(function () {
$('table tr td').on('click', '.add', function () {
var value = parseInt($(this).next(':first').val());
$(this).next(':first').val(value + 1);
})
$('table tr td').on('click', '.remove', function () {
var value = parseInt($(this).prev(':first').val());
$(this).prev(':first').val(value - 1);
})
$('table tr td').on('click', '.clear', function () {
$(this).siblings('.show').val(0);
})
})
</script>
<table>
<tr>
<td>
<asp:Button runat="server" CssClass="add" ID="Add" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" CssClass="show" ID="num" Height="25px" Style="margin-top: 0px" Width="73px">0</asp:TextBox>
<asp:Button runat="server" CssClass="remove" ID="reduce" Text="-" Height="34px" Width="38px" />
<asp:Button runat="server" CssClass="clear" ID="delete" Text="清空" Height="33px" Width="61px" />
</td>
</tr>
<tr>
<td>
<asp:Button runat="server" CssClass="add" ID="Button1" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" CssClass="show" ID="TextBox1" Height="25px" Style="margin-top: 0px" Width="73px">0</asp:TextBox>
<asp:Button runat="server" CssClass="remove" ID="Button2" Text="-" Height="34px" Width="38px" />
<asp:Button runat="server" CssClass="clear" ID="Button3" Text="清空" Height="33px" Width="61px" />
</td>
</tr>
<tr>
<td>
<asp:Button runat="server" CssClass="add" ID="Button4" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" CssClass="show" ID="TextBox2" Height="25px" Style="margin-top: 0px" Width="73px">0</asp:TextBox>
<asp:Button runat="server" CssClass="remove" ID="Button5" Text="-" Height="34px" Width="38px" />
<asp:Button runat="server" CssClass="clear" ID="Button6" Text="清空" Height="33px" Width="61px" />
</td>
</tr>
</table>
[/quote]清空有用 可是加减没有用 
<table>
<tr>
<td>
<asp:Button runat="server" CssClass="add" ID="Add" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" CssClass="show" ID="num" Height="25px" Style="margin-top: 0px" Width="73px">0</asp:TextBox>
<asp:Button runat="server" CssClass="remove" ID="reduce" Text="-" Height="34px" Width="38px" />
<asp:Button runat="server" CssClass="clear" ID="delete" Text="清空" Height="33px" Width="61px" />
</td>
</tr>
<tr>
<td>
<asp:Button runat="server" CssClass="add" ID="Button1" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" CssClass="show" ID="TextBox1" Height="25px" Style="margin-top: 0px" Width="73px">0</asp:TextBox>
<asp:Button runat="server" CssClass="remove" ID="Button2" Text="-" Height="34px" Width="38px" />
<asp:Button runat="server" CssClass="clear" ID="Button3" Text="清空" Height="33px" Width="61px" />
</td>
</tr>
<tr>
<td>
<asp:Button runat="server" CssClass="add" ID="Button4" Text="+" Height="33px" Width="52px" />
<asp:TextBox runat="server" CssClass="show" ID="TextBox2" Height="25px" Style="margin-top: 0px" Width="73px">0</asp:TextBox>
<asp:Button runat="server" CssClass="remove" ID="Button5" Text="-" Height="34px" Width="38px" />
<asp:Button runat="server" CssClass="clear" ID="Button6" Text="清空" Height="33px" Width="61px" />
</td>
</tr>
</table>
<table>
<tr>
<td>
<input class="add" type="button" value="+" />
<input class="show" type="text" value="0" />
<input class="remove" type="button" value="-" />
<input class="clear" type="button" value="清空" />
</td>
</tr>
<tr>
<td>
<input class="add" type="button" value="+" />
<input class="show" type="text" value="0" />
<input class="remove" type="button" value="-" />
<input class="clear" type="button" value="清空" />
</td>
</tr><tr>
<td>
<input class="add" type="button" value="+" />
<input class="show" type="text" value="0" />
<input class="remove" type="button" value="-" />
<input class="clear" type="button" value="清空" />
</td>
</tr>
</table>
$(function () {
$('table tr td').on('click', '.add', function () {
var value =parseInt($(this).next(':first').val());
$(this).next(':first').val(value + 1);
})
$('table tr td').on('click', '.remove', function () {
var value = parseInt($(this).prev(':first').val());
$(this).prev(':first').val(value - 1);
})
$('table tr td').on('click', '.clear', function () {
$(this).siblings('.show').val(0);
})
})