Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2010
    Location
    Philippines
    Posts
    15
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Exclamation Help! how to add another textbox?

    Hi, Goodday to all. I have this kind of problem which i need to add another textbox in a fillup form.

    example:

    Name: (there is a textbox here)
    Description: (there's another textbox here too)
    Add Field: (this is what I'm talking about!)

    I need a button or something that can add another textbox realtime in that same page. And another field in mysql that ill be using for that particular new textbox that will be created.

    All in all I need a php hardcode for that. please let me know if someone has idea on this. Thanks!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    Adding the textbox in realtime will be Javascripting (or JQuery),
    as PHP will require a page refresh. Look here on Google:
    http://www.google.com/search?q=addin...ng&btnG=Search

    The MySQL part would be PHP ... as it would determine it needs a new column
    when the form is processed. Whether or not you really meant to add a column
    to the table, I'm not sure. I would not mess with any MySQL tables unless you
    do some serious validation and make sure things should be added.

    Adding records (or rows) is one thing ... adding columns (fields) is very different.

  • Users who have thanked mlseim for this post:

    lexjoshua (08-06-2010)

  • #3
    New Coder
    Join Date
    Aug 2010
    Location
    Philippines
    Posts
    15
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thanks for the reply, so you mean it's kinda impossible?

    javascript part:
    when the user press "add new field" button. the textbox will appear.

    php part:
    then when he press the "save" button it will somewhat execute to create a new field in the table of my database wherein the value of textbox will be stored?

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,456
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    It's not impossible,
    just make sure you do some verifying and checking
    to make sure nobody is adding anything malicious.

    When you add a new field to your table, you are affecting
    the whole table (all of the existing rows). You then have to
    be able to read stuff from the new fields. Because you'll
    never know when new fields are created, your script will have
    to query the table for field (column) names each time.

    Any outputs to the screen (as in a database list) will have to
    find and display the new columns also. It could affect page layouts.

    What if someone decides to add 500 of them?
    And what size and type are the fields?

    Maybe you need to think outside the box, and add the new textboxes
    as rows instead of columns. I of course don't have any background on
    what your project is supposed to do, or what your goal is.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •