| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1914 人关注过本帖
标题:javascript页面中怎么取得变量值后自动填入?
只看楼主 加入收藏
nnwind
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2017-2-4
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
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>&nbsp;
                    <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>
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<asp:Button
                        ID="Button2" runat="server" Text="保存成绩" OnClick="Button2_Click" />&nbsp;
                    <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>
搜索更多相关主题的帖子: javascript color 前台 
2017-02-04 09:50
nnwind
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2017-2-4
收藏
得分:0 
这句为什么没起作用?
图片附件: 游客没有浏览图片的权限,请 登录注册
2017-02-04 09:52
nnwind
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2017-2-4
收藏
得分:0 
后台代码:
程序代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class inputstudentscore : System.Web.UI.Page
{
    CommDB mydb = new CommDB();
    DataSet myds = new DataSet();
    string mysql;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            mysql = "SELECT cno FROM course WHERE tno='" + Session["uno"] + "'";
            myds = mydb.ExecuteQuery(mysql, "course");
            if (myds.Tables["course"].Rows.Count > 0)
            {
                DropDownList1.DataSource = myds.Tables["course"];
                DropDownList1.DataTextField = "cno";
                DropDownList1.DataBind();
            }
            else
                Response.Redirect("~/dispinfo.aspx?info=没有安排任何考核!");
            Button2.Visible = false;
            Button3.Visible = false;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string mysql;
        mysql = "SELECT * FROM score WHERE tno='" + Session["uno"] + "'AND cno ='" + DropDownList1.SelectedValue + "' ORDER BY sno";
        myds = mydb.ExecuteQuery(mysql, "score");
        if (myds.Tables["score"].Rows.Count > 0)
        {
            GridView1.DataSource = myds.Tables["score"];
            GridView1.DataBind();
            Button2.Visible = true;
            Button3.Visible = true;
        }
        else
            Response.Write("<script>alert('没有员工选考或提交该考核!')</script>");

    }
    protected void Button2_Click(object sender, EventArgs e)
    {   //保存成绩
        savedata();
        Response.Redirect("~/dispinfo.aspx?info=输入的成绩已保存!");
    }
    protected void savedata()  //保存成绩过程
    {
        string no;
        TextBox txtbh;
        int i;
        for (i = 0; i < GridView1.Rows.Count; i++)
        {
            no = GridView1.Rows[i].Cells[0].Text;    //提取该行的用户名
            txtbh = GridView1.Rows[i].FindControl("TBox11") as TextBox;
            //在该行中找TextBox1控件
            Update(no, txtbh.Text);                    //调用自定义过程进行更新
            txtbh = GridView1.Rows[i].FindControl("TBox22") as TextBox;
            //在该行中找TextBox2控件
            Update1(no, txtbh.Text);                //调用自定义过程进行更新
            txtbh = GridView1.Rows[i].FindControl("TBox33") as TextBox;
            //在该行中找TextBox3控件
            Update2(no, txtbh.Text);                //调用自定义过程进行更新
        }
    } 

    protected void Update(string no, string fs)
    //自定义过程,用UPDATE语句修改分数
    {
        mysql = "UPDATE score SET degree=" + fs + " WHERE sno = '" +
            no + "' AND cno='" + DropDownList1.SelectedValue + "'";
        mydb.ExecuteNonQuery(mysql);
    }  
    protected void Update1(string no, string fs)
    //自定义过程,用UPDATE语句修改分数
    {
           mysql = "UPDATE score SET jidu=" + fs + " WHERE sno = '" +
            no + "' AND cno='" + DropDownList1.SelectedValue + "'";    
        mydb.ExecuteNonQuery(mysql);
    }  
    protected void Update2(string no, string fs)
    //自定义过程,用UPDATE语句修改分数
    {
           mysql = "UPDATE score SET year=" + fs + " WHERE sno = '" +
            no + "' AND cno='" + DropDownList1.SelectedValue + "'";    
        mydb.ExecuteNonQuery(mysql);
    }  
}
    
2017-02-04 09:53
wangjy500
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:贵宾
威 望:13
帖 子:457
专家分:2569
注 册:2010-7-11
收藏
得分:20 
document.getElementById('_41').value = var000;
    document.getElementById('TBox11').value = var000;

QQ:63572063
2017-02-06 15:58
ke爱的小tu子
Rank: 2
等 级:论坛游民
帖 子:51
专家分:20
注 册:2021-2-11
收藏
得分:0 
一直都搞不懂,为什么样式必须和html混编在一起。这样真的看起来很不简洁。
2021-02-11 14:30
快速回复:javascript页面中怎么取得变量值后自动填入?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032978 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved