?
Solved

Real quick.

Posted on 2003-03-31
10
Medium Priority
?
123 Views
Last Modified: 2013-12-24
got a form that ask how many rows to return in the next form. (ex 5)

upon submit the new form has 5 rows of the same fields.

my problem lies here

upon submiting the form that now has 5 rows with the same field names, iwould like to do the following,

1.  show the user what is about to be inserted like this.

yourname >> your>> other>> fields
yourname >> your>> other>> fields
yourname >> your>> other>> fields
yourname >> your>> other>> fields
yourname >> your>> other>> fields

it is showing up like this:
yourname, your, other, fields,yourname, your, other, fields,yourname, your, other, fields,yourname, your, other, fields,yourname, your, other, fields

2.  I would then insert those records into the db 1 row per db record.

any help would be greatly appreciated..
0
Comment
Question by:jriver12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 4

Expert Comment

by:crosenblum
ID: 8240038
What data would be used to populate that breadcrumb?

I am not sure what you are trying to do.

0
 

Author Comment

by:jriver12
ID: 8240101
example:

howmany page:

How many rows do you need for the data >>5>> submit>>


Return page
now has 5 rows containing the following fields:
(all named the same)
Name>>Company>> Ceo>>Date>>somethingelse<<
Name>>Company>> Ceo>>Date>>somethingelse<<
Name>>Company>> Ceo>>Date>>somethingelse<<
Name>>Company>> Ceo>>Date>>somethingelse<<
Name>>Company>> Ceo>>Date>>somethingelse<<

Now I know that on submit being that these fields are all named the same therefore they will be displayed as a list.

What I am trying to figure out is how to break the list at the end of the last item in that row and then insert those rows into the db  as individual rows.

thanks

hope that this cleared it up for you.
0
 
LVL 8

Accepted Solution

by:
TallerMike earned 600 total points
ID: 8240133
In reality, you should NEVER name inputs the same name UNLESS they are checkboxes or radio options. Text inputs should ALWAYS have a unique name within the form.

With that said, one option is to take that row number and use it to create unique names for the inputs like so:

<input type="hidden" name="numberOfRows" value="#form.numberOfRows#">
<cfloop from="1" to="#form.numberOfRows#" index="rowCount">
  <input type="text" name="yourname_#rowCount#">
  <input type="text" name="your_#rowCount#">
  <input type="text" name="other_#rowCount#">
  <input type="text" name="fields_#rowCount#">
</cfloop>

******************************************************************************************
******************************************************************************************

Then your processing page should loop through the numberOfRows variable and evaluate the input values, SOMETHING (but maybe not exactly) like so:

<cfloop from="1" to="#form.numberOfRows#" index="rowCount">
<cfscript>
  yourname = Evaluate("yourname_#rowCount#");
  your = Evaluate("your_#rowCount#");
  other = Evaluate("other_#rowCount#");
  fields = Evaluate("fields_#rowCount#");
</cfscript>
*** Do your output / update within this loop ***
</cfloop>
0
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 

Author Comment

by:jriver12
ID: 8240156
example:

howmany page:

How many rows do you need for the data >>5>> submit>>


Return page
now has 5 rows containing the following fields:
(all named the same)
Name>>Company>> Ceo>>Date>>somethingelse<<
Name>>Company>> Ceo>>Date>>somethingelse<<
Name>>Company>> Ceo>>Date>>somethingelse<<
Name>>Company>> Ceo>>Date>>somethingelse<<
Name>>Company>> Ceo>>Date>>somethingelse<<

Now I know that on submit being that these fields are all named the same therefore they will be displayed as a list.

What I am trying to figure out is how to break the list at the end of the last item in that row and then insert those rows into the db  as individual rows.

thanks

hope that this cleared it up for you.
0
 
LVL 3

Expert Comment

by:cdillon
ID: 8240183
Here is my coding interpretation of what you are trying to do. You will need to modify it to fit your case:

<cfquery name="myquery" datasource="#dsn#">
  select * from originaltable
</cfquery>

<cfloop index="counter" from="1" to="#form.number_selected#">
#myquery.Name#&gt;&gt;#myquery.Company#&gt;&gt; #myquery.Ceo#&gt;&gt;#myquery.Date#&gt;&gt;#myquery.somethingelse#&lt;&lt;
</cfloop>

<cfloop index="counter" from="1" to="#form.number_selected#">

<cfquery name="copies" datasource="#dsn#">
   insert into destinationtable(name,company,ceo,date,somethingelse) values('#myquery.Name#','#myquery.Company#', '#myquery.Ceo#','#myquery.Date#','#myquery.somethingelse#')
</cfquery>

</cfloop>
0
 

Author Comment

by:jriver12
ID: 8240260
example:

howmany page:

How many rows do you need for the data >>5>> submit>>


Return page
now has 5 rows containing the following fields:
(all named the same)
Name>>Company>> Ceo>>Date>>somethingelse<<
Name>>Company>> Ceo>>Date>>somethingelse<<
Name>>Company>> Ceo>>Date>>somethingelse<<
Name>>Company>> Ceo>>Date>>somethingelse<<
Name>>Company>> Ceo>>Date>>somethingelse<<

Now I know that on submit being that these fields are all named the same therefore they will be displayed as a list.

What I am trying to figure out is how to break the list at the end of the last item in that row and then insert those rows into the db  as individual rows.

thanks

hope that this cleared it up for you.
0
 
LVL 8

Expert Comment

by:TallerMike
ID: 8240331
jriver12, please do NOT refresh the page. Please use the "Reload This Question" link at the top of the left navigation menu. When you refresh, you repost your last comment.
0
 
LVL 10

Expert Comment

by:substand
ID: 8240392
on the submit page where you display all the fields of the same name, make sure to include:

<input type="hidden" name="num_selected" value="#form.num_selected#">

of course, replacing form.num_selected with whatever you named the field in the first form.

on the submit page where you INSERT the data you would do:

<cfloop from="1" to="#form.num_selected#" index="cnt">

<cfset curRowIndex=(cnt-1)*5>

<cfquery name="insert" datasource="#datasourceName#">
insert into tablename (name, company, ceo, date, somethingelse) values
(#listgetat(form.field_that_is_named_the_same, curRowIndex+1)#,#listgetat(form.field_that_is_named_the_same, curRowIndex+2)#,#listgetat(form.field_that_is_named_the_same, curRowIndex+3)#,#listgetat(form.field_that_is_named_the_same, curRowIndex+4)#,#listgetat(form.field_that_is_named_the_same, curRowIndex+5)#)

</cfquery>

</cfloop>

you better hope the user doesn't use a comma in thier response though, as this will screw everything up and there is no way to fix it.  Personally, I would use TallerMike's approach- as it won't get broken by user input.
0
 
LVL 11

Expert Comment

by:hart
ID: 8243530
i would suggest that you go with Tallermikes suggestion,

but if u r going to continue with yours.
then all you have to do is this.. or forget it.

i strongly feel u should go with Tallermikes suggestion..

Regards
Hart(harish)
0
 

Author Comment

by:jriver12
ID: 8255224
Thanks, I apologize for taking so long.
0

Featured Post

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question