• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Getting Data

Participant ,
Dec 02, 2008 Dec 02, 2008

Copy link to clipboard

Copied

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?
TOPICS
Advanced techniques

Views

420

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 02, 2008 Dec 02, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 03, 2008 Dec 03, 2008

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 03, 2008 Dec 03, 2008

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 03, 2008 Dec 03, 2008

Copy link to clipboard

Copied

LATEST
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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation