By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,492 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,492 IT Pros & Developers. It's quick & easy.

help with javascript

P: n/a
i need to use javascript in the following 2 situations but dont know how and
thanks in advance:

1. i have 2 textboxes and they usually contain the same information. when
the user starts entering data in the 1st textbox, the data should also appear
in the 2nd textbox. if needed, the user can modify the data in the 2nd
textbox.

2. i have a textbox and a control beside it. the textbox should have a max.
no. of char. allowed and the control beside it reminds the user how many more
chars. can be entered. as the user enters characters, the control starts
counting down. an example of this is Carfax's textbox for entering the VIN #.
Nov 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Newbie,

I'm a little rusty on my Javascript. =)

For each of these, you will want to attach an event handler for the
textbox so that when it changes, your method is fired (look for an onChange
event). Then, in the event handler, you can modify the contents of the
other textbox, or get the length of the current text and set a label to that
number to show how many characters are typed.

Also, for textboxes, I believe you can set the length attribute in the
input tag to indicate the maximum length of the contents of the textbox.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Newbie" <Ne****@discussions.microsoft.com> wrote in message
news:E0**********************************@microsof t.com...
i need to use javascript in the following 2 situations but dont know how
and
thanks in advance:

1. i have 2 textboxes and they usually contain the same information. when
the user starts entering data in the 1st textbox, the data should also
appear
in the 2nd textbox. if needed, the user can modify the data in the 2nd
textbox.

2. i have a textbox and a control beside it. the textbox should have a
max.
no. of char. allowed and the control beside it reminds the user how many
more
chars. can be entered. as the user enters characters, the control starts
counting down. an example of this is Carfax's textbox for entering the VIN
#.

Nov 17 '05 #2

P: n/a
Hi,

this is a C# NG, you would get a better answer at a javascript NG, take a
look at the onchange event of the input control

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Newbie" <Ne****@discussions.microsoft.com> wrote in message
news:E0**********************************@microsof t.com...
i need to use javascript in the following 2 situations but dont know how
and
thanks in advance:

1. i have 2 textboxes and they usually contain the same information. when
the user starts entering data in the 1st textbox, the data should also
appear
in the 2nd textbox. if needed, the user can modify the data in the 2nd
textbox.

2. i have a textbox and a control beside it. the textbox should have a
max.
no. of char. allowed and the control beside it reminds the user how many
more
chars. can be entered. as the user enters characters, the control starts
counting down. an example of this is Carfax's textbox for entering the VIN
#.

Nov 17 '05 #3

P: n/a
Use the following code,
script:
<SCRIPT language="javascript">
function keyUp()
{
document.all("TextBox4").value = document.all("TextBox2").value;
document.all("TextBox5").value = 100 -
document.all("TextBox2").value.length;
}
</SCRIPT>
design:

<asp:TextBox id="TextBox2" runat="server" onkeyup="keyUp();"></asp:TextBox>
<asp:TextBox id="TextBox4" runat="server"></asp:TextBox>
<asp:TextBox id="TextBox5" runat="server"></asp:TextBox></form>

--
Regards,
Amal [MCP, MCS]
http://geocities.com/techsharing
"Newbie" wrote:
i need to use javascript in the following 2 situations but dont know how and
thanks in advance:

1. i have 2 textboxes and they usually contain the same information. when
the user starts entering data in the 1st textbox, the data should also appear
in the 2nd textbox. if needed, the user can modify the data in the 2nd
textbox.

2. i have a textbox and a control beside it. the textbox should have a max.
no. of char. allowed and the control beside it reminds the user how many more
chars. can be entered. as the user enters characters, the control starts
counting down. an example of this is Carfax's textbox for entering the VIN #.

Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.