0
The Array Insertin Loop
Participant
,
/t5/coldfusion-discussions/the-array-insertin-loop/td-p/953556
Apr 25, 2008
Apr 25, 2008
Copy link to clipboard
Copied
I am trying to insert the values in the database where one
value is just like ID of the form and other values are based on the
checkbox values. I dump the data and they appear as:
struct
FIELDNAMES SELEMAILS,THELISTVAL
SELEMAILS 4,3,5,6
THELISTVAL 16
array
1 4
2 3
3 5
4 6
So the above SELEMAILS value was coming as list and i converted this to array.
and there after i want to insert the data in the database.
but i am stuck in inserting.
I want to loop over the array and then insert the value but i do not know how
Also the checkbox will increase if i select more checkboxes, and how will i insert the value 16 for that.
Like i want my database to appear like this:
eid checkboxid
16 3
16 4
16 5
16 6
and if list of checkboxes increase, the dynamic eid value should alo increase.
I am creating something like this:
<cfform method="post" action="do.cfm">
<tr> <cfoutput>
<div>Displaying <b>#URL.startRow#</b> to <b>#endRow#</b> of <b>#totalRows#</b> Records</div>
</cfoutput>
<div align="left">
<!---<cfinclude template="nextn.cfm">--->
</div>
<cfloop query="qUsers" startRow="#URL.startRow#" endrow="#endRow#">
<cfoutput>
<cfif variables.newrow EQ true>
<tr>
</cfif>
<td align="LEFT">
<CFINPUT type="checkbox" name="selEmails" value="#userid#" required="yes" message="Select least 1 to continue." tooltip="Choose Emails to send the Event Letter">
<cfif session.mytype EQ 'admin' OR session.mytype EQ 'moderator'><cfelse>
<a href="mailto:#useremail#">#FullLeft(useremail,10)#...</a></cfif> </td>
<cfif qUsers.currentRow MOD 4 EQ 0>
</tr>
<cfset variables.newrow = true>
<cfelse>
<cfset variables.newrow = false>
</cfif>
</cfoutput>
</cfloop>
</tr>
<input type="hidden" name="theListVal" value="<cfoutput>#form.thespecificevents#</cfoutput>">
<tr><td colspan="4"> </td></tr>
<tr>
<td colspan="4"><input type="submit" value="Send to Checked Email Addresses" tabindex="1" class="longPost" onMouseOver="this.className='longPost_over'" onMouseOut="this.className='longPost'" /></td>
</tr>
</cfform>
Well can Someone Plz Guide me in this?
struct
FIELDNAMES SELEMAILS,THELISTVAL
SELEMAILS 4,3,5,6
THELISTVAL 16
array
1 4
2 3
3 5
4 6
So the above SELEMAILS value was coming as list and i converted this to array.
and there after i want to insert the data in the database.
but i am stuck in inserting.
I want to loop over the array and then insert the value but i do not know how
Also the checkbox will increase if i select more checkboxes, and how will i insert the value 16 for that.
Like i want my database to appear like this:
eid checkboxid
16 3
16 4
16 5
16 6
and if list of checkboxes increase, the dynamic eid value should alo increase.
I am creating something like this:
<cfform method="post" action="do.cfm">
<tr> <cfoutput>
<div>Displaying <b>#URL.startRow#</b> to <b>#endRow#</b> of <b>#totalRows#</b> Records</div>
</cfoutput>
<div align="left">
<!---<cfinclude template="nextn.cfm">--->
</div>
<cfloop query="qUsers" startRow="#URL.startRow#" endrow="#endRow#">
<cfoutput>
<cfif variables.newrow EQ true>
<tr>
</cfif>
<td align="LEFT">
<CFINPUT type="checkbox" name="selEmails" value="#userid#" required="yes" message="Select least 1 to continue." tooltip="Choose Emails to send the Event Letter">
<cfif session.mytype EQ 'admin' OR session.mytype EQ 'moderator'><cfelse>
<a href="mailto:#useremail#">#FullLeft(useremail,10)#...</a></cfif> </td>
<cfif qUsers.currentRow MOD 4 EQ 0>
</tr>
<cfset variables.newrow = true>
<cfelse>
<cfset variables.newrow = false>
</cfif>
</cfoutput>
</cfloop>
</tr>
<input type="hidden" name="theListVal" value="<cfoutput>#form.thespecificevents#</cfoutput>">
<tr><td colspan="4"> </td></tr>
<tr>
<td colspan="4"><input type="submit" value="Send to Checked Email Addresses" tabindex="1" class="longPost" onMouseOver="this.className='longPost_over'" onMouseOut="this.className='longPost'" /></td>
</tr>
</cfform>
Well can Someone Plz Guide me in this?
TOPICS
Getting started
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/the-array-insertin-loop/m-p/953557#M87153
Apr 25, 2008
Apr 25, 2008
Copy link to clipboard
Copied
The simplest way is to first make sure that checkboxid is
defined, and if so, loop through the list (no array is necessary)
and insert your records inside the loop.
and insert your records inside the loop.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/coldfusion-discussions/the-array-insertin-loop/m-p/953558#M87154
Apr 25, 2008
Apr 25, 2008
Copy link to clipboard
Copied
> I want to loop over the array and then insert the value
but i do not know how
How have you tried to do this? Which part are you getting stuck on? Have
you read the docs on CF arrays, and all the various array functions
available to you?
You've posted your form, but not your form-action code, which is what
you're asking about.
Post the bits of your code that you're having problems with, with a
description of what you've tried, and why it didn't seem to work.
--
Adam
How have you tried to do this? Which part are you getting stuck on? Have
you read the docs on CF arrays, and all the various array functions
available to you?
You've posted your form, but not your form-action code, which is what
you're asking about.
Post the bits of your code that you're having problems with, with a
description of what you've tried, and why it didn't seem to work.
--
Adam
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

