1 Reply Latest reply on Oct 20, 2006 6:52 AM by Newsgroup_User

    Multiple Inserts based on check box

    mikeap
      I have a simple form with the attached code in it. The second bit of attached code is my action page. The delete is not happening and the new insert based on the checkbox selection is not happening.

      Is using cfif FORM.whichRSM NEQ "" not the correct method?
        • 1. Re: Multiple Inserts based on check box
          Level 7
          I used this and it worked fine. I was using the database to populate the
          options / checkboxes, so you might need to tweek to code if you have static
          checkbox names. I also am only inserting information, so you would want to
          put a delete SQL statement into the mix before / after:

          <cfloop list="#form.fieldnames#" index="field">
          <!--- If the field is a list field --->
          <cfif (left(field,4) EQ "LIST")>
          <CFQUERY Name="ListElement" DataSource="mailer">
          INSERT INTO Optouttable (name,email,outoption)
          VALUES ('#form.name#','#form.email#', #form[field]#)
          </cfquery>
          </cfif>
          </cfloop>

          Then for the form I had:


          <form action="" method="post" name="showMeMy">
          <cfoutput>
          <cfset i = 0>
          <cfloop query="optionList">
          <table width="100%" border="0">
          <cfset i = i+1>
          <tr>
          <td width="19%"><div align="right">
          <input name="list#i#" type="checkbox" id="list#i#"
          value="#optionList.listid#">
          </div></td>
          <td width="81%">#optionList.listName#</td>
          </tr>
          </table>
          <input name="Update" type="submit" id="Update" value="Unsubscribe">
          </cfloop>
          </cfoutput>
          </form>

          Not sure if this will work for you, but it might be a step in the right
          direction.