1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2011
    Rep Power

    How to get values from dynamically created textbox to save in db

    Hi Guys i am creating dynamic text boxes and i want to store their values into db,.

    any help will be apreciated ..


    code of a quick example of dynamic generated textbox is below:

    <script language="javascript">
    function init()
    //element with NO id
    // newFieldElementNoId = document.createElement( 'INPUT' );
    // newFieldElementNoId.onblur = show;
    // document.body.appendChild(newFieldElementNoId);

    //element with id
    var i;
    for ( i=0;i<5;i++)
    newFieldElement = document.createElement( 'INPUT' );
    newFieldElement.onblur = show;
    function show(){

    alert( 'id=' + this.getAttribute('id') + "\n" + 'name=' + this.getAttribute('name') + "\n" + "value=" + this.value );
    <body onload="init()">
  2. #2
  3. No Profile Picture

    Join Date
    Jun 2002
    Raleigh, NC
    Rep Power
    One option is to pass a hidden form field that you update to specify the number of dynamic fields (i.e. "3"). When you submit the form, you know there are 3 fields so you can loop from 1 to 3 (or whatever number you pass as the total count) and reference each of them by name and number.

    You can also use form.fieldList to get a list of all the form fields that were submitted, and determine how many dynamic fields there are that way.

    Or, you can use something like my Form Utilities CFC which lets you name the fields with an array syntax (i.e. "myField[3]" and have CF automatically convert it into an array that you can then loop over.

IMN logo majestic logo threadwatch logo seochat tools logo