Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Mar 2010
    Location
    Gainesville, FL
    Posts
    3
    Member #
    21580
    I need to be able to add extra text boxes to my site dynamically. The user is provided a single text box by default to enter data. But if they need to enter more than one line, I want there to be a button to have another box appear. I have seen this done on other sites, but I can't think of one.
    What is the best way to do this? Javascript?

  2.  

  3. #2
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Yes, javascript. If you're familiar with jQuery, this is very easy to make. Simply append() more boxes when the user clicks() a button.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  4. #3
    Junior Member luker's Avatar
    Join Date
    Apr 2010
    Posts
    7
    Member #
    21586
    I agree with the jquery route. Here's a good example and tutorial on how to add form elements dynamically:

    Tutorial:
    http://www.coldfusionjedi.com/index....dd-form-fields

    Demo:
    http://www.coldfusionjedi.com/demos/jqueryadd/test1.cfm

    Hope this helps.

  5. #4
    Senior Member
    Join Date
    Feb 2005
    Location
    Canada
    Posts
    435
    Member #
    8983
    HTML Code:
    <script type="text/javascript">
    var pos = 0;
    function addbox()
    {
    var place = document.getElementById('THE_ID_OF_PLACE');
    place.innerHTML += '<input type="text" id="entry' + pos + '" />'
    }
    </script>
    Rudimentary but works
    Thee Pyro Wolf

  6. #5
    Junior Member
    Join Date
    Mar 2010
    Location
    Gainesville, FL
    Posts
    3
    Member #
    21580
    Thanks for all the responses. I'll be giving it a shot sometime this week after I get some other stuff off my plate.
    I have also be reading up on Ruby. Since I don't know much about Ruby, I won't be designing my site with it anytime soon, but this type of thing seems almost native to Ruby... can anyone comment on that?

  7. #6
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Ruby, on Rails, is a web application framework. I don't have much experience with it, so I can't exactly say if it'll do what you want, but note that in the end Javascript is the only thing that can accomplish your goal. (RoR may generate the JS, I do not know.)
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  8. #7
    Junior Member
    Join Date
    Mar 2010
    Location
    Gainesville, FL
    Posts
    3
    Member #
    21580
    Quote Originally Posted by Steax
    Ruby, on Rails, is a web application framework. I don't have much experience with it, so I can't exactly say if it'll do what you want, but note that in the end Javascript is the only thing that can accomplish your goal. (RoR may generate the JS, I do not know.)
    Good to know. I'll keep that in mind. Like I said, I'm really just starting to read about it to see if it's something I want to pursue. In the end though, my site is pretty simple and really doesn't need anything above and beyond some simple HTML, JS, PHP.
    Thanks.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:28 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com