macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

Re: insert multiple checkboxes

Subject: Re: insert multiple checkboxes
From: GArlington
Date: Thu, 16 Aug 2007 09:14:12 -0700
Newsgroups: macromedia.coldfusion.cfml_general_discussion
On 16 Aug, 16:58, "Rcain37" <[email protected]> wrote:
> I have a query that generates a list and each field has a check box.  I want 
> to
> be able to check  multiple boxes and insert them into a new table.
>
>  This is what I have so far.  Page1.cfm works correctly but once I submit the
> form and hit the action page, I start getting errors.
>
>  [B]Page1.cfm[/B]
>
>  <cfquery name="listnames" datasource="bs">
>  SELECT     PBT_LISTNAME, ID
>  FROM         PBT_BILLS_LISTS
>  WHERE     PBT_USERNAME = '#session.userdata.username#'
>  and            pbt_year = #year#
>  order by pbt_listname
>  </cfquery>
>
>  <CFFORM action="Action.cfm">
>  <cfloop query="listnames" startrow="#start_lists#" endrow="#end_lists#">
>
>  <tr>
>  <td>
>  <input type="Checkbox" value="#id#" name="id">  #pbt_listname#
>  <input type="hidden" value="#pbt_listname#" name="pbt_listname">
>  </td>
>  </tr>
>
>  <tr>
>  <td>
>  <select name="PBT_HOUSEORIG">
>  <option value="h">House
>  <option value="s">Senate
>  </select>
>
>  <select name="PBT_BILLTYPE">
>  <option value="b">Bill
>  <option value="r">Resolution
>  <option value="cr">Concurrent Resolution
>  <option value="jr">Joint Resolution
>  </select>
>
>  <CFINPUT required="Yes" message="You must enter a Bill Number!" type="text"
> name="PBT_BILLNUM" maxLength="100" size=4> (eg. 123)
>
>  <INPUT type="hidden" name="PBT_USERNAME" value="#session.userdata.username#"
> maxLength="100">           <INPUT type="hidden" name="PBT_YEAR" value="#year#"
> maxLength="8">
>  <INPUT type="hidden" name="PBT_ID" value="#CreateUUID()#" maxLength="100">
>  <input type="Submit" value="Update Lists" name="btn_uplists">
>
>  <br>
>  <br>
>
>  </td>
>  </tr>
>
>  </table>
>
>  <hr noshade width="880px" align="left">
>  </cfform>
>
>  [B]Action.cfm[/B]
>  I know I need to loop through the query below and I only want to insert that
> data when the value for the checkbox on Page1.cfm is checked.
>
>  This is the error that I am getting.
>   Attribute validation error for tag cfloop.
>  The value of the attribute query, which is currently "updatelists", is 
> invalid.
>
>  <CFELSEIF ParameterExists(form.btn_uplists)>
>  <CFQUERY DATASOURCE="bs" name="updatelists">
>                 INSERT INTO PBT_BILLS
>                 (               pbt_listname,
>                                 PBT_HOUSEORIG,
>                                 PBT_BILLTYPE,
>                                 PBT_BILLNUM,
>                                 PBT_ID,
>                                 PBT_USERNAME,
>                                 PBT_YEAR
>                                  ) VALUES (
>  <CFQUERYPARAM CFSQLType="CF_SQL_Varchar" Value="#Form.pbt_listname#">,
>  <CFQUERYPARAM CFSQLType="CF_SQL_Varchar" Value="#Form.PBT_HOUSEORIG#">,
>  <CFQUERYPARAM CFSQLType="CF_SQL_Varchar" Value="#Form.PBT_BILLTYPE#">,
>  <CFQUERYPARAM CFSQLType="CF_SQL_Varchar" Value="#Form.PBT_BILLNUM#">,
>  <CFQUERYPARAM CFSQLType="CF_SQL_Varchar" Value="#Form.PBT_ID#">,
>  <CFQUERYPARAM CFSQLType="CF_SQL_Varchar" Value="#Form.PBT_USERNAME#">,
>  <CFQUERYPARAM CFSQLType="CF_SQL_Varchar" Value="#Form.PBT_YEAR#">
>  )
>
>                 </CFQUERY>
>                 <cfloop query="updatelists"></cfloop>
>
>  Any help would be greatly appreciated.
>
>  Thanks

1) Try to write structured html output. 2) In order to UPDATE the DB
with VALUES from FORM - (think about it) - you have to process ALL
values of form.blahblah variables and update DB with each value. You
do not have the query returned from your form, just the list of vars.


<Prev in Thread] Current Thread [Next in Thread>