javascript页面中怎么取得变量值后自动填入?
其中,分数下面这个打算写入的数据ID是TBox11 ,读取的数据ID来自 _41
现在分数这个值,需要手动输入,怎么才能在“合计”算出来的时候,自动填入到分数框里?
**************************************************************************************
前台代码如下:
程序代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="inputstudentscore.aspx.cs" Inherits="inputstudentscore" StylesheetTheme="Blue" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.> <html xmlns="http://www. > <head runat="server"> <title>无标题页</title> <link href="link.css" rel="stylesheet" type="text/css" /> <link href="../link.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" runat="server"> <div> <table align="center" style="background-color: #ABFCB0"> <tr> <td style="width: 456px; height: 22px; text-align: center"> <strong><span style="font-size: 14pt; color: #ff00cc; font-family: 仿宋_GB2312">输入我的员工成绩</span></strong></td> </tr> <tr> <td style="width: 456px; height: 40px; text-align: center"> <span style="font-size: 10pt; color: #0000ff"><strong>考核: </strong></span> <asp:DropDownList ID="DropDownList1" runat="server" Font-Bold="True" Font-Size="10pt" Width="113px"> </asp:DropDownList> <asp:Button ID="Button1" runat="server" Font-Size="10pt" OnClick="Button1_Click" Text="确定" /></td> </tr> <tr> <td style="width: 456px; height: 23px"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="0" Font-Bold="True" Font-Size="10pt" ForeColor="Black" GridLines="None" Height="5px" Width="456px" > <FooterStyle BackColor="Tan" /> <Columns> <asp:BoundField DataField="sno" HeaderText="用户名"> <ItemStyle HorizontalAlign="Center" /> </asp:BoundField> <asp:BoundField DataField="sname" HeaderText="姓名"> <ItemStyle HorizontalAlign="Center" /> </asp:BoundField> <asp:BoundField DataField="cno" HeaderText="考核号"> <ItemStyle HorizontalAlign="Center" /> </asp:BoundField> <asp:BoundField DataField="cname" HeaderText="考核岗位"> <ItemStyle HorizontalAlign="Center" /> </asp:BoundField> <asp:TemplateField HeaderText="分数"> <EditItemTemplate> <asp:TextBox ID="TBox1" runat="server" Text='<%# Bind("degree") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:TextBox ID="TBox11" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"degree") %>' Width="25px"></asp:TextBox> </ItemTemplate> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> <asp:TemplateField HeaderText="季度"> <EditItemTemplate> <asp:TextBox ID="TBox2" runat="server" Text='<%# Bind("jidu") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:TextBox ID="TBox22" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"jidu") %>' Width="25px"></asp:TextBox> </ItemTemplate> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> <asp:TemplateField HeaderText="年度"> <EditItemTemplate> <asp:TextBox ID="TBox3" runat="server" Text='<%# Bind("year") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:TextBox ID="TBox33" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"year") %>' Width="30px"></asp:TextBox> </ItemTemplate> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> </Columns> <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" /> <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" /> <HeaderStyle BackColor="Tan" Font-Bold="True" /> <AlternatingRowStyle BackColor="PaleGoldenrod" /> </asp:GridView> <asp:Button ID="Button2" runat="server" Text="保存成绩" OnClick="Button2_Click" /> <input type="reset" ID="Button3" runat="server" Text="取消" /></td> </tr> </table> </div> </form> </form> <p>请在黄色框内输入数字,将自动计算小计及合计。</p> <SCRIPT language="javascript"> function SumNum10() { var sumValue20 a10=eval(_21.value); b10=eval(_22.value) if (isNaN(a10)) {a10=0} if (isNaN(b10)) {b10=0} sumValue21 = a10/b10; self['_30'].value =sumValue21; var sumValue30 a10=eval(_21.value); b10=eval(_22.value) if (isNaN(a10)) {a10=0} if (isNaN(b10)) {b10=0} sumValue30 = a10/b10*25; self['_40'].value =sumValue30;add() } </script> <table width="800" border="1" cellspacing="2" cellpadding="10"> <tr> <th width="30" scope="col">服务满意度</th> <th width="40" scope="col">业务部门全员问券评分</th> <th width="20" scope="col">> 8分</th> <th width="10" scope="col">25</th> <th width="40" scope="col">满意度表平均分值</th> <th width="40" bgcolor="#FFFF00" scope="col"><input id="_21" type="text" size="5" onkeyup="value=value.replace(/[^\d\.]/g,'');SumNum10();"></th> <th width="40" bgcolor="#FFFF00" scope="col"><input id="_22" type="text" size="5" onkeyup="value=value.replace(/[^\d\.]/g,'');SumNum10();"></th> <th width="40" scope="col"><input id="_30" type="text" size="5"></th> <th width="40" scope="col"><input id="_40" type="text" size="5"></th> </tr> </table> </script> <script type="text/javascript"> function add(){ // 如果不是数字,或者没有填写就默认为0 var var000 = parseFloat(document.getElementById('_40').value) || 0; document.getElementById('_41').value = var000; document.getElementById('TBox11').value = document.getElementById('_41').value; } </script> <table width="800" border="1" cellspacing="2" cellpadding="10"> <tr> <th width="30" scope="col">合计</th> <th width="40" scope="col"><input id="_41" type="text" size="5"></th> </tr> </table> </body> </html>