473,804 Members | 3,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript into ASP.Net Simple example wanted.. Sum Textboxes client side

I would like to have a total box show the totol of four textboxes when
anyone of them change.

I know I could do this via postback, but would like to do this on client
side utilizing javascript.

I am familiar with asp.net but not in how to migrate javascript into the
html.

Thanks,

Rog
Nov 18 '05 #1
4 2622
if you want it with clientside javascript I suggest you look at a clientside
javascript newsgroup.
you'll probably have to catch the keydown/keyup in the boxes.

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Davisro" <NA> wrote in message
news:ed******** ******@tk2msftn gp13.phx.gbl...
I would like to have a total box show the totol of four textboxes when
anyone of them change.

I know I could do this via postback, but would like to do this on client
side utilizing javascript.

I am familiar with asp.net but not in how to migrate javascript into the
html.

Thanks,

Rog

Nov 18 '05 #2
Here is one idea (will need tweaking):

<input type="text" id="sumBox" name="sumBox" onFocus="SumBox es();" />
<script language="JavaS cript">
function SumBoxes()
{
var val1 = form1.addBox1.V alue;
var val2 = form2.addBox1.V alue;
var val3 = form3.addBox1.V alue;
var val4 = form4.addBox1.V alue;

//May need test for "" on each box here, turn to 0, like
if(val1 == '')
{
val1 = 0;
}

form1.sumBox.Va lue = val1 + val2 + val3 + val4;
}
</script>

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** *************** *************** *************** ***
Think outside the box!
*************** *************** *************** *************** ***
"Davisro" <NA> wrote in message
news:ed******** ******@tk2msftn gp13.phx.gbl...
I would like to have a total box show the totol of four textboxes when
anyone of them change.

I know I could do this via postback, but would like to do this on client
side utilizing javascript.

I am familiar with asp.net but not in how to migrate javascript into the
html.

Thanks,

Rog

Nov 18 '05 #3
I would like to use WebForm Textboxes as I have a lot of .Net code that
relates to them. Is this possible in mostly the same way you stated above?

Thanks,

Rog
"Cowboy (Gregory A. Beamer) [MVP]" <No************ @comcast.netNoS pamM> wrote
in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Here is one idea (will need tweaking):

<input type="text" id="sumBox" name="sumBox" onFocus="SumBox es();" />
<script language="JavaS cript">
function SumBoxes()
{
var val1 = form1.addBox1.V alue;
var val2 = form2.addBox1.V alue;
var val3 = form3.addBox1.V alue;
var val4 = form4.addBox1.V alue;

//May need test for "" on each box here, turn to 0, like
if(val1 == '')
{
val1 = 0;
}

form1.sumBox.Va lue = val1 + val2 + val3 + val4;
}
</script>

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** *************** *************** *************** ***
Think outside the box!
*************** *************** *************** *************** ***
"Davisro" <NA> wrote in message
news:ed******** ******@tk2msftn gp13.phx.gbl...
I would like to have a total box show the totol of four textboxes when
anyone of them change.

I know I could do this via postback, but would like to do this on client
side utilizing javascript.

I am familiar with asp.net but not in how to migrate javascript into the
html.

Thanks,

Rog


Nov 18 '05 #4
For insert JavaScript on client page you can use RegisterClientS criptBlock
or RegisterStartup Script method.
string s = "<script language=\"Java Script\">\n" +
"function SumBoxes()\n" +
"{\n" +
............
"}\n" +
"</script>\n";

RegisterClientS criptBlock("SUM ", s);

for attach this function to your textbox you can use this code :
txtBox1.Attribu tes["OnChange"] = "SumBoxes() ;";

Brun

"Davisro" <NA> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
I would like to use WebForm Textboxes as I have a lot of .Net code that
relates to them. Is this possible in mostly the same way you stated above?
Thanks,

Rog
"Cowboy (Gregory A. Beamer) [MVP]" <No************ @comcast.netNoS pamM> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Here is one idea (will need tweaking):

<input type="text" id="sumBox" name="sumBox" onFocus="SumBox es();" />
<script language="JavaS cript">
function SumBoxes()
{
var val1 = form1.addBox1.V alue;
var val2 = form2.addBox1.V alue;
var val3 = form3.addBox1.V alue;
var val4 = form4.addBox1.V alue;

//May need test for "" on each box here, turn to 0, like
if(val1 == '')
{
val1 = 0;
}

form1.sumBox.Va lue = val1 + val2 + val3 + val4;
}
</script>

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** *************** *************** *************** ***
Think outside the box!
*************** *************** *************** *************** ***
"Davisro" <NA> wrote in message
news:ed******** ******@tk2msftn gp13.phx.gbl...
I would like to have a total box show the totol of four textboxes when
anyone of them change.

I know I could do this via postback, but would like to do this on client side utilizing javascript.

I am familiar with asp.net but not in how to migrate javascript into the html.

Thanks,

Rog



Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1358
by: Harry | last post by:
Hello, I have an ASP.Net web page populated with WebControls, such as textboxes and checkboxes. On this page I also have a JavaScript that disables these textboxes under certain events (such as "onLoad" and "onClick") by calling the javascript method <object>.disabled = <true/false>. This works visably fine on the webpage, however, when I do a postback to the server and check the <WebControl>.Enabled property on an item I disabled via the...
4
256
by: Davisro | last post by:
I would like to have a total box show the totol of four textboxes when anyone of them change. I know I could do this via postback, but would like to do this on client side utilizing javascript. I am familiar with asp.net but not in how to migrate javascript into the html. Thanks,
27
4764
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it appears that the data goes straight to the processing page, rather than the javascript seeing if data is missing and popping up an alert. I thought it may be because much of the form is populated with data from the db (lists, etc.), but when I leave...
0
9707
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.