help with javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Newbie

    help with javascript

    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 #.
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: help with javascript

    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]
    - mvp@spam.guard. caspershouse.co m


    "Newbie" <Newbie@discuss ions.microsoft. com> wrote in message
    news:E09E405C-D28C-44F8-9FC3-B8BE9826FD0E@mi crosoft.com...[color=blue]
    >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
    > #.[/color]


    Comment

    • Ignacio Machin \( .NET/ C# MVP \)

      #3
      Re: help with javascript

      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" <Newbie@discuss ions.microsoft. com> wrote in message
      news:E09E405C-D28C-44F8-9FC3-B8BE9826FD0E@mi crosoft.com...[color=blue]
      >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
      > #.[/color]


      Comment

      • AMALORPAVANATHAN YAGULASAMY(AMAL)MCP,MCS

        #4
        RE: help with javascript

        Use the following code,
        script:
        <SCRIPT language="javas cript">
        function keyUp()
        {
        document.all("T extBox4").value = document.all("T extBox2").value ;
        document.all("T extBox5").value = 100 -
        document.all("T extBox2").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]
        Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!



        "Newbie" wrote:
        [color=blue]
        > 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 #.[/color]

        Comment

        Working...