C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...









Adding TextBox Values using Javascript


Posted Date: 11 Jun 2008    Resource Type: Code Snippets    Category: Javascript

Posted By: Bharathi       Member Level: Diamond
Rating:     Points: 7



The following code sample shows how to add the textbox values using javascript.

The keyup event of the textbox is used. Three textboxes is use , the functionality is to add the first and second textboxes and total in third textbox.

The Javascript Function follows :


function KeyUpEvent()
{
var txt1 = document.getElementById("txt1");
var txt2 = document.getElementById("txt2");
var txt3 = document.getElementById("txt3");
if ((txt1.value != "") && (txt2.value != ""))
{
txt3.value = parseInt(txt1.value) + parseInt(txt2.value);
}
}


Design



<asp:TextBox ID="txt1" runat="server"></asp:TextBox>
<asp:TextBox ID="txt2" runat="server"></asp:TextBox>
<asp:TextBox ID="txt3" runat="server"></asp:TextBox>


To add attributes to the textbox at code behind use this example:


txt1.Attributes.Add("onKeyUp", "javascript:KeyUpEvent();");
txt2.Attributes.Add("onKeyUp", "javascript:KeyUpEvent();");




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Javascript KeyUp Event  .  Add textbox values  .  Add textbox contents on keyup using javascript  .  Add textbox contents on keyup  .  Add textbox contents  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Programatically Firing Events in Javascript
Previous Resource: How to find the Control Location Using JavaScript
Return to Discussion Resource Index
Post New Resource
Category: Javascript


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

internet fax

Contact Us    Privacy Policy    Terms Of Use