473,406 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Displaying text from a textbox into a label onKeydown

Hi eveyone,

Right this is my first post as i'm new to the forum.

I'm trying to work out how to display text, typed into a text box, into a label on the keypress of the client.

So as they type into the text box it is displayed in a label or another text box that is disabled from user accessability.

Don't mind what format it is in but i have been looking at both AJAX & Javascript to try and solve the problem.

Has anyone got any ideas?

Cheers all!

Dan
Jun 13 '07 #1
3 3489
dmjpro
2,476 2GB
Hi eveyone,

Right this is my first post as i'm new to the forum.

I'm trying to work out how to display text, typed into a text box, into a label on the keypress of the client.

So as they type into the text box it is displayed in a label or another text box that is disabled from user accessability.

Don't mind what format it is in but i have been looking at both AJAX & Javascript to try and solve the problem.

Has anyone got any ideas?

Cheers all!

Dan

Welcome to TSDN.
u need not to do it with AJAX.
it is possible with JS.

try this code ....

Expand|Select|Wrap|Line Numbers
  1. <input type = text onkeypress = updateLabel(this.value)>
  2. <h3 id = my_label>Empty Label</h3>
  3.  

Expand|Select|Wrap|Line Numbers
  1. function updateLabel(val)
  2. {
  3.   var label_ref = document.getElementById('my_label');
  4.   label_ref.innerText = val;
  5. }
  6.  
I think it ll help u.
Best of luck
have agood day.

Kind regards,
Dmjpro.
Jun 13 '07 #2
Welcome to TSDN.
u need not to do it with AJAX.
it is possible with JS.

try this code ....

Expand|Select|Wrap|Line Numbers
  1. <input type = text onkeypress = updateLabel(this.value)>
  2. <h3 id = my_label>Empty Label</h3>
  3.  

Expand|Select|Wrap|Line Numbers
  1. function updateLabel(val)
  2. {
  3.   var label_ref = document.getElementById('my_label');
  4.   label_ref.innerText = val;
  5. }
  6.  
I think it ll help u.
Best of luck
have agood day.

Kind regards,
Dmjpro.
Thanks DMJPRO,

I have tried it and it does do what is says on the tin but it seems to be a key stroke behind.

http://www.upperlevel.co.uk/development/testtext.html

See what you think?

Is this because it uses keypress instead of keydown or keyup? Just guessing here.

Thanks,

UpperLevel
Jun 13 '07 #3
Thanks DMJPRO,

I have tried it and it does do what is says on the tin but it seems to be a key stroke behind.

http://www.upperlevel.co.uk/development/testtext.html

See what you think?

Is this because it uses keypress instead of keydown or keyup? Just guessing here.

Thanks,

UpperLevel
Hi again,

Sorted it now, needed to be onkeyup!

Code:

<script language="javascript" type="text/javascript">

function updateLabel(val)
{
var label_ref = document.getElementById('my_label');
label_ref.innerText = val;
}

</script>

Page:

<input type = "text" onkeyup = "updateLabel(this.value)" /><br/>
<span class="style3" id = "my_label">Empty Label</span>

Cheers,

UpperLevel
Jun 13 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
8
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
12
by: brwalias | last post by:
Hi, using .net 2 sql server 2005 Here is my situation: I'm passing a variable in the url from a selection on Page A and need to display the results on the Results page be based on that...
6
by: IReallyNeedHelp | last post by:
I have saved the questions using AddQuestion.aspx page i have created but i don't know how to display it and calculate their score. this is the formview i have done, but there is some error ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.