4 Replies Latest reply on Dec 3, 2008 2:24 PM by dchard

    Getting Data

    Level 1
      I have a page here that add rows with 3 textbox after pressing the button. The added textbox have all unique name. My question is how can I access the data on the added textbox in the next page if I don't know how many rows will be added?
        • 1. Re: Getting Data
          Dan Bracuk Level 5
          Your code is unreadable so I'll just tell you how I do it.

          On the form page, the fields will have names like text1, text2, etc.

          On the action page, I do something like this.

          <cfloop list="#form.fieldnames#" (or whatever the right name is) index ="ThisField">
          <cfif left(ThisField, 4) is "text">
          <cfset ThisID = removechars(ThisField, 4)>
          <cfset ThisValue = form[ThisField]>

          and then carry on with whatever you want to do.
          • 2. Re: Getting Data
            Level 1
            var oCell = newRow.insertCell(0);
            oCell.height = '25';
            oCell.vAlign = 'middle';
            oCell.align = 'center';
            oCell.style.background = '#EEEEEE';
            oCell.innerHTML = "<input type='text' name='textfieldA[]' class='bodytext' size='20' align='center'>";

            oCell = newRow.insertCell(1);
            oCell.height = '25';
            oCell.vAlign = 'middle';
            oCell.align = 'center';
            oCell.style.background = '#EEEEEE';
            oCell.innerHTML = "<input type='text' name='textfieldB[]' class='bodytext' size='35' align='center'>";

            oCell = newRow.insertCell(2);
            oCell.height = '25';
            oCell.vAlign = 'middle';
            oCell.align = 'center';
            oCell.style.background = '#EEEEEE';
            oCell.innerHTML = "<input type='text' name='textfieldC[]' class='bodytext' size='3' align='center'>";

            if I'm going to change the name of the textbox I'm going to add into an array. How can I access the data on each textbox on the nextpage?

            • 3. Re: Getting Data
              Dan Bracuk Level 5
              When you submit the form, there will be no array of textboxes unless you create one. I don't see that being necessary and the approach in my previous answer will work in your situation.
              • 4. Re: Getting Data
                Level 1
                that's my javascript is doing....after you click the add order it will add another row with three textbox.....so basically after clicking the link it will also create an array of textbox