Reply to topic
Need help here
Ennio


Joined: 17 Nov 2006
Posts: 98
Location: Scotch Plains, NJ
Reply with quote
I have 5 <cfinput> that I need to be save on my DB.

But the problem is that on my DB I have only 2 columns one for the ID and the other for the value from the <cfinput>

What is the best way to do this and not use 5 Insert, one for each <cfinput>.
Is there a way to loop thru the <cfinput>?
Jason101
Forum Regular

Joined: 14 Mar 2006
Posts: 547
Location: Harrisburg, PA
Reply with quote
Ennio,

If you name the input boxes the same, when you submit the form the values will be put into a list in the form variable of whatever you named all the text boxes.

You can then loop through the list to do your inserts.
shill


Joined: 17 Feb 2007
Posts: 6
Location: Knoxville, TN
Reply with quote
Ennio,

Jason was kind enough to answer similar question for me a couple of weeks ago. You can read the thread here:

http://forums.hostmysite.com/viewtopic.php?t=3917

This may help.

Susie
Ennio


Joined: 17 Nov 2006
Posts: 98
Location: Scotch Plains, NJ
Reply with quote
Hi guys thank you, I found this solution that worked for me.

Code:

<cfif  structKeyExists(form,"txtgoal" & x)>
    <cfset location = form['txtgoal' & x] >
 <cfelse>
    <cfset location = "">
 </cfif>
Jason101
Forum Regular

Joined: 14 Mar 2006
Posts: 547
Location: Harrisburg, PA
Reply with quote
I always recommend StructKeyExists() over isDefined

Sean CorField will even back that up Laughing

http://corfield.org/blog/index.cfm/do/blog.entry/entry/isDefined_vs_structKeyExists
Need help here
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT  
Page 1 of 1  

  
  
 Reply to topic