[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Pass value from one textbox to anothet

Posted on 2009-04-27
6
Medium Priority
?
307 Views
Last Modified: 2012-05-06
Hello Guys! I have a combo box which has two values namely Allowence and Accommodation. When Allowence is selected, the focus is shifted to a text box to enter the value. Once the value is entered, I want that value to be in another text box. How can I do that and under which control should I write the code. Something like this.
txtemphraallowence = txtemphracost
0
Comment
Question by:preethamonline
6 Comments
 
LVL 2

Expert Comment

by:neo00000110
ID: 24243073
i'd use

txtemphraallowence.text = txtemphracost.text

put this on the textchangeed event of txtemphracost. If you're using webforms make sure autopostback is set to true.
0
 
LVL 9

Accepted Solution

by:
tetorvik earned 2000 total points
ID: 24243229
i would do it with javascript:
on page_load attach onblur attribute on textbox where you want to copy from and attribute value is a javascript statement to copy the entered value.
No postbacks required...

//page_load         
   txt2.Attributes.Add("onblur", 
                String.Format("javascript:document.getElementById('{0}').value=document.getElementById('{1}').value;", txt1.ClientID, txt2.ClientID));

Open in new window

0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 24244467
i will ask a question before i suggest a solution
why - what is the need to copy the text from one text box to another?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:preethamonline
ID: 24245155
Well ragi, i have a drop down list with 2 values. One is allowence and the other is accomodation.
I have 2 text boxes. One for allowence and the other called ctc.
So when a value is entered in allowence text box i also want it to appear in the ctc box, so that it helps calculating the CTC (Cost to company) of the employee.

I hope its not confusing. I have attached a sample screenshot of what i'm trying to achieve.
HRA-Example.bmp
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 24247556
the solution provided by tetorvik should do the trick for you
0
 

Author Comment

by:preethamonline
ID: 24252494
Thanks guys.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question