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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subscribe/ Unsubscribe

Status
Not open for further replies.

neomorpheus

Programmer
Mar 9, 2001
47
US
I a m currently developing an application that lets users subscribe to newsletters and am having trouble proceeding. I give the users a radio button option (Yes/No) to pick from. Based on what is picked/ not picked, I need to create a string which will be fed to a stored Procedure that inserts the data into a table. My problem is in creating that "String". My Form Fields debug output look like this:

--------------------------------
BI-WEEKLY=0
DD NEWSLETTER=0
EC=0
ESSA CC=1
FIELDNAMES=BI-WEEKLY,DD NEWSLETTER,EC,ESSA CC,INFO-DT,MK_COMM_YES,TALK LISTS,UPDATE
INFO-DT=0
MK_COMM_YES=1
TALK LISTS=0
UPDATE=Update Subscriptions

--------------------------------
The names of the newsletters comes from a table and hence dynamic. My resulting string based on whats selected needs to be in the form of:

BI-WEEKLY&0,DD NEWSLETTER&0,EC&0,ESSA CC&1,INFO-DT&0,MK_COMM_YES&1,TALK LISTS&0

Where "0" means unsubscribe (radio Uncheck) and "1" is Subscribe (Radio Checked) and the "&" is a deliniter that is used by the Stored Procedure.

This is the string that i need to submit to the Stored Proc and I need help creating this.

Please Help!

My Code:
*************************************************
<cfloop query = &quot;qListRulesSelect&quot;>
<tr bgcolor=&quot;#tblbgcolor#&quot;>
<td><div align=&quot;left&quot;>
#qClientListRulesSelect.ListRule#
</div></td>
<td><div align=&quot;left&quot;>
#qClientListRulesSelect.ListRuleDescription#
</div></td>

<!--- The YES Radio Button --->
<td>
<div align=&quot;left&quot;>
<center>
<input type=radio name=&quot;#qListRulesSelect.ListRule#&quot; <cfif qListRulesSelect.checked IS &quot;1&quot;>checked</cfif> value=&quot;1&quot;>
</center>
</div>
</td>

<!--- The NO Radio Button --->
<td>
<div align=&quot;left&quot;>
<center>
<input type=radio name=&quot;#qListRulesSelect.ListRule#&quot; <cfif qListRulesSelect.checked IS &quot;0&quot;>checked</cfif> value=&quot;0&quot;>
</center>
</div>
</td>

</cfloop>

<tr bgcolor=&quot;#tblbgcolor#&quot;>
<td colspan=4><div align=&quot;left&quot;>
<center><input type=&quot;Submit&quot; value=&quot;Update Subscriptions&quot; name=&quot;Update&quot; class=button></center>
</div></td>
</tr>
****************************************************

Thanks in advance.
 
This is pretty straightforward. Your CF template that processes this form can create the list that you need by looping through the FIELDNAMES list (ignoring the field &quot;UPDATE&quot;). You must eliminate spaces and hyphens in the names of your form fields. Copy and paste the following code into an empty CF template and execute the template. Of course, you will delete the lines between CFOUTPUT tags in your final version.

<cfscript>
fieldnames = &quot;BI_WEEKLY,DD_NEWSLETTER,EC,ESSA_CC,INFO_DT,MK_COMM_YES,TALK_LISTS,UPDATE&quot;;
BI_WEEKLY=&quot;0&quot;;
DD_NEWSLETTER=&quot;0&quot;;
EC=&quot;0&quot;;
ESSA_CC=&quot;1&quot;;
INFO_DT=&quot;0&quot;;
MK_COMM_YES=&quot;1&quot;;
TALK_LISTS=&quot;0&quot;;
UPDATE=&quot;Update Subscriptions&quot;;
</cfscript>

<cfset mystring = &quot;&quot;>
<cfloop index=&quot;field&quot; list=&quot;#fieldnames#&quot;>
<cfif field neq &quot;update&quot;>
<cfoutput>
fieldname=#field#<br>
value=#evaluate(field)#<P>
</cfoutput>
<cfset mystring = listappend(mystring, &quot;#field#&#evaluate(field)#&quot;)>
</cfif>
</cfloop>

<cfoutput>
#mystring#
</cfoutput>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top