Display text box automatically after pressing enter key in first text box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kaleeswaran
    New Member
    • Mar 2007
    • 132

    Display text box automatically after pressing enter key in first text box

    hi!
    in my web page...after i am insert the value into text box then i press enter then next text box should display automatically.h ow to do that....
    thank you,
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by kaleeswaran
    hi!
    in my web page...after i am insert the value into text box then i press enter then next text box should display automatically.h ow to do that....
    thank you,
    [code=html]
    <input type = text onkeypress = "showText(event )">
    [/code]

    [code=javascript]
    function showText(e)
    {
    var key = e.which ? e.which : e.keyCode;
    if(key == 13)
    {
    //your next processing code goes here
    }
    }
    [/code]

    Debasis Jana

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Changed the thread title to better describe the problem.

      Comment

      • kaleeswaran
        New Member
        • Mar 2007
        • 132

        #4
        how to display the dynamic text box using javascript

        hi!
        i need to display the text box dynamically after the customer enter the key...i am having idea we can do using onkeypress event.but i don't know how to that.
        so please tell me some idea....
        thank you,
        Last edited by kaleeswaran; Oct 9 '07, 01:47 PM. Reason: questions is not clear

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Which part have you got difficulty with? Detecting the enter key or displaying a text box dynamically?

          Comment

          • kaleeswaran
            New Member
            • Mar 2007
            • 132

            #6
            i feel difficult in both part but now i am getting some idea through you given keycode function now my doubt is how to create the text box dynamically?...
            thanks,

            Comment

            • dmjpro
              Top Contributor
              • Jan 2007
              • 2476

              #7
              Originally posted by kaleeswaran
              i feel difficult in both part but now i am getting some idea through you given keycode function now my doubt is how to create the text box dynamically?...
              thanks,
              Having a look at my code.
              [code=javascript]
              var text_ref = document.create Element("input" );
              text_ref.setAtt ribute("type"," text");
              .
              .
              document.body.a ppendChild(text _ref);
              [/code]

              Debasis Jana

              Comment

              • kaleeswaran
                New Member
                • Mar 2007
                • 132

                #8
                Hi,

                i have dynamically created a table with two rows and have inserted text boxes in each column./ Textboxes have also been inserted dynamically. My question is how do i find the id of the textboxes currently being used..
                thank you,

                Comment

                • dmjpro
                  Top Contributor
                  • Jan 2007
                  • 2476

                  #9
                  Originally posted by kaleeswaran
                  Hi,

                  i have dynamically created a table with two rows and have inserted text boxes in each column./ Textboxes have also been inserted dynamically. My question is how do i find the id of the textboxes currently being used..
                  thank you,
                  [code=html]
                  <input type = "text" id = "some_id" onkeypress = "getId(this.id) ">
                  [/code]

                  [code=javascript]
                  function getId(id)
                  {
                  alert(id);
                  }
                  [/code]

                  Debasis Jana

                  Comment

                  Working...