通过使用javascript在更新时获取文本框值而无需保存在数据库中 [英] Getting textbox value while updating without saving in database by using javascript

查看:66
本文介绍了通过使用javascript在更新时获取文本框值而无需保存在数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我的Java脚本有问题,
我正在使用6个文本框和一个总计文本框,如果我将值添加到6个文本框,它将增加并在总计文本框中显示总计,并且将所有六个文本框值保存到数据库中,但总计未存储到数据库中不需要,并且我的问题是,如果我更新这些值,则总值未显示在总文本框中,请plz尽快告诉我..


预先感谢

hi All ,
i have a problem with java script,
i am using 6 text boxes and one total text box,if i add the values to 6 text boxes it will increase and total shown in total text box and ill save all six text box values into database but total is not stored into database that is not needed , and my problem is if i update these values the total value is not shown in the total text box what is the code behind that plz tell me ASAP..


Thanks in advance

推荐答案

您后面的代码(在服务器端)无法识别JavaScript(在客户端)所做的更改.要克服这个问题,您可以执行以下两项操作之一:
1.使用隐藏的输入字段,例如
You code behind (on Server-Side) does not recognize changes that are made by JavaScript (on Client-Side). To overcome this there''s one of two things you can do:
1. Use hidden input field e.g.
<input id="inputTotal" runat="server" type="hidden" />


存取您的总数:


Access your total:

String myTotal = inputTotal.value;




2.使用ajax传输数据而不必回发整个页面,并且在Google上有很多有关此教程,例如
http://www.tutorialspoint.com/ajax/ [




2. Use ajax to transfer data without having to post back your entire page and there are many tutorials for that on google e.g.
http://www.tutorialspoint.com/ajax/[^]




我们无法访问服务器端由javascript更改的值.

为了克服这个问题,您可以使用会话变量来存储所需的数据.因此,我们不需要使用数据库.

首先,我们必须以异步方式将更改的数据传递给服务器.

为了更好地理解''m在此处提供了一些示例..

Hi,

we can not access values changed by javascript in server side.

To overcome this you can use session variables to store required data.by this we no need to use database.

First we''ve to pass the changed data to server in asynchronous manner.

For better understanding ''m providing some example here..

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script language="javascript" >
        function setval() {


(" #TextBox1").text( 这是测试");
("#TextBox1").text("hi this is testing");


这篇关于通过使用javascript在更新时获取文本框值而无需保存在数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆