add textbox to already created page using javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhishek92
    New Member
    • Jul 2007
    • 9

    #1

    add textbox to already created page using javascript

    I have made a page. I need a provision that when a person selects the number of items from dropdown box ... that number of textboxes should be displayed so that he can enter description about all items...

    I think this can either be done by -
    1. displaying that number of boxes on the same page..
    or
    2. By popping a window with selected number of text boxes..

    I want to do it by 1st method...

    I think this is a simple problem... If anybody can help please.....
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    use a for-loop to create and append new textboxes with createElement() , appendChild()-methods. first create a empty div within your document where you want your boxes to appear - that acts as your textboxes-container ... append the textboxes then to it during the loop ...

    hope i gave you the idea ... try something and ask more question when you have them ... post some code you tried ...

    kind regards ...

    Comment

    • abhishek92
      New Member
      • Jul 2007
      • 9

      #3
      thanks ....
      the method is working but there is a problem...
      For first change in selected value this works fine...
      And the text boxes gets displayed..

      but when I again change the value in the <select> tag new textboxes get appended to earlier made textboxes...


      For this firstly I have to delete earlier added elements , but how?
      Please guide me further.....

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        ... loop through the elements in your div and use removeChild() ...

        kind regards ...

        Comment

        • abhishek92
          New Member
          • Jul 2007
          • 9

          #5
          Originally posted by gits
          ... loop through the elements in your div and use removeChild() ...

          kind regards ...
          thanks
          and my code is now working fine...
          instead of adding textboxes I used different strategy..

          I created div tag.. added needed number of textboxes to that tag and then add that tag to the main tag..

          next time I just removed the old div tag and then created new div tag and add it..

          Thanks again

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            glad you got it working ... ;)

            come back if you have more questions ...

            kind regards ...

            Comment

            Working...