Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SENDING DATA ENTERED AT ONCE -- HELP !!

Status
Not open for further replies.

kingjjx

Programmer
Joined
Sep 18, 2001
Messages
181
Location
US
How can you send several entries to the same column for the same table at once ?
Example: I have a table called EMPLOYEES and a column for LASTNAME, FIRSTNAME .. right now the only way I know how to do it is let the user fill up the form fill up last name and first name and click send then do it again ...
how do i do it that in 1 form I can have 5 different entries for Last Name and First Name and COldFUsion will send it at once.
Ex:
PLEASE ENTER INFORMATION:
Fname:_________ Lname: _________

Fname:_________ Lname: _________

Fname:_________ Lname: _________

SEND

HERE'S MY CODE RIGHT NOW:
THIS IS THE FORM PAGE::
<form mehod=&quot;post&quot; action=&quot;jcentry2.cfm&quot;>
<p>First Name:
<input type=&quot;TEXT&quot; Name=&quot;fname&quot;>
<br>
Last Name:
<Input type=&quot;Text&quot; Name=&quot;lname&quot;>
<input type=&quot;SUBMIT&quot; VALUE=&quot;SUBMIT&quot;>

THIS IS THE CODE FOR THE INSERT/ACTION PAGE:
<Cfquery name=&quot;addjcode&quot; datasource=&quot;Timesheets&quot;>
Insert into Jobcodes (Fname, Lname) VALUES ('#fname#', '#lname#')
</cfquery>


Please help thanks.

 
roughly:

THIS IS THE FORM PAGE::
<form mehod=&quot;post&quot; action=&quot;jcentry2.cfm&quot;>
<p>First Name:
<input type=&quot;TEXT&quot; Name=&quot;fname1&quot;>
<br>
Last Name:
<Input type=&quot;Text&quot; Name=&quot;lname1&quot;>
<p>First Name:
<input type=&quot;TEXT&quot; Name=&quot;fname2&quot;>
<br>
Last Name:
<Input type=&quot;Text&quot; Name=&quot;lname2&quot;>
<p>First Name:
<input type=&quot;TEXT&quot; Name=&quot;fname3&quot;>
<br>
Last Name:
<Input type=&quot;Text&quot; Name=&quot;lname3&quot;>
<p>First Name:
<input type=&quot;TEXT&quot; Name=&quot;fname4&quot;>
<br>
Last Name:
<Input type=&quot;Text&quot; Name=&quot;lname4&quot;>
<p>First Name:
<input type=&quot;TEXT&quot; Name=&quot;fname5&quot;>
<br>
Last Name:
<Input type=&quot;Text&quot; Name=&quot;lname5&quot;>
<input type=&quot;SUBMIT&quot; VALUE=&quot;SUBMIT&quot;>

THIS IS THE CODE FOR THE INSERT/ACTION PAGE:
<CFLOOP from=1 to=5 index=&quot;loopcount&quot;>
<CFSET currF=&quot;fname#loopcount#&quot;>
<CFSET currL=&quot;lname#loopcount#&quot;>
<Cfquery name=&quot;addjcode&quot; datasource=&quot;Timesheets&quot;>
Insert into Jobcodes (Fname, Lname)
VALUES('#evaluate(currF)#', '#evaluate(currL)#')
</cfquery>
</CFLOOP>

that should do the trick.. I used similar code in a custom tag once... let me know if does/doesn't...
 
Hey, this worked great, but if I leave a field blank it gives me an error message. How do you make it accept blank fields ?

thanks
-jon
 
Change:
<CFSET currF=&quot;fname#loopcount#&quot;>
<CFSET currL=&quot;lname#loopcount#&quot;>
To:
<CFPARAM name=&quot;fname#loopcount#&quot; default=&quot;&quot;>
<CFPARAM name=&quot;lname#loopcount#&quot; default=&quot;&quot;>
<CFSET currF=&quot;fname#loopcount#&quot;>
<CFSET currL=&quot;lname#loopcount#&quot;>

If you have AIM, you can message me as webmigit.. let me know if it works out alright
 
Hey .. below is what the action page looks like and it still doesnt allow me to leave fields empty ..

<CFLOOP from=1 to=5 index=&quot;loopcount&quot;>

<CFPARAM name=&quot;fname#loopcount#&quot; default=&quot; &quot;>
<CFPARAM name=&quot;lname#loopcount#&quot; default=&quot; &quot;>
<CFSET currF=&quot;fname#loopcount#&quot;>
<CFSET currL=&quot;lname#loopcount#&quot;>
<CFIF currF is &quot;&quot;>
<CFSET currF=&quot; &quot;>
</CFIF>
<CFIF currL is &quot;&quot;>
<CFSET currL=&quot; &quot;>
</CFIF>

<Cfquery name=&quot;addjcode&quot; datasource=&quot;Timesheets&quot;>
Insert into trial (Fname, Lname)
VALUES('#evaluate(currF)#', '#evaluate(currL)#')
</cfquery>
</CFLOOP>


IF YOU WANNA CHECK IT OUT ... ITS IN
 
The error is probably database generated. Verify your column is set to except null=yes required=no DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
hey, if you can please help me out ...
what is this part of the code actually doing :

VALUES('#evaluate(currF)#', '#evaluate(currL)#')
</cfquery>
</CFLOOP>

** you can scroll up to see the rest ...
my question is it is saying ('#evaluate(currF)#', --> is this because i named the field Fname ? what if I named it Jobcode .. or m1 ? would it be (evaluate(currJ)#' ????? and (evaluate(currM)? .. if so what if I have a field called m1 and another called m2 ???

please advice, i really need this.
thank you
 
hey, how do i do this if i have 4 or 5 fields that needs to be looped (that needs to be inserted at once) ..

ex...
FNAME
LNAME
AGE
SEX
RACE

FNAME
LNAME
AGE
SEX
RACE

and so on ... ????
pelase help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top