Quantcast
Channel: Adobe Community : Popular Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 14291

Looping insert using CFC

$
0
0
I am stuck on this. I have a form that loops the number of textboxes based
on a user choice. I want to enter these into a database using a CFC, but it
keeps telling me that the textbox title 'name' does not exist and I am
confused on how to procede. I attempted to change the name/id to just 'name'
but that didn't go over well as expected.
Here is the form, the invoke, and then the CFC.
Please help, its the last step of a project that I want to get finished.
Everything works just fine, except for the insert. Thanks!

Form:
<form id="addguests" name="addguests" method="post" action="">
<table width="100%" border="0">
<tr>
<td colspan="2">
<cfloop index="i" from="1" to="#Form.guests#">
<table width="100%" border="0">
<cfoutput>
<tr>
<td><div align="right"><strong>Guest #i#
Name:</strong></div></td>
<td><input name="name#i#" " type="text" id="name#i#"
" value="" size="25" /></td>
</tr>
<tr>
<td><div align="right"><strong>Guest #i#
Description:</strong></div></td>
<td><input name="description#i#" type="text"
id="description#i#" " value="" size="65" /><input name="show_id"
type="hidden" id="show_id" value="#URL.Show#" />
<input name="guest" id="guest" value="#nog#" type="hidden" /> </td>
</tr>
</cfoutput></table></cfloop></td>
</tr>
<tr>
<td width="25%"> </td>
<td width="75%"><input name="Submit_Add" type="submit"
class="small_buttn" id="Submit_Add" value="Add Guests" /></td>
</tr>
</table>
</form>

Invoke:
<cfif IsDefined ('Submit_Add')>
<cfloop index="i" from="1" to="#Form.guest#">
<cfinvoke component="#Shows#" method="AddGuests">
<cfinvokeargument name="show" value="#URL.show#">
</cfinvoke>
</cfloop>
<cflocation url="index.cfm?show=added" addtoken="no">
</cfif>

CFC:
<cffunction name="AddGuests" access="public" returntype="void">
<cfargument name="show" type="numeric" required="yes">
<cfquery name="AddGuests" datasource="mydb">
INSERT INTO RadioShowGuests (name, descript, show)
Values ('#Form.name#', '#Form.description#', #arguments.show#)
</cfquery>
</cffunction>



Viewing all articles
Browse latest Browse all 14291

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>