Skip to main content
Known Participant
Aug 21, 2006 7:52 PM UTC
Answered

checkbox problem

Ok, I know this should be relatively simple, but I can't seem to get this to work! The same syntax works on my select fields, just no the checkbox fields. I have a table of users, a table of orgs, and and user_org table that joins the 2.

I am creating a simple update form. In the previous screen, a user is selected, then the user_id for that user is sent to the next page where the details for that user are managed. The form is only checking the checkbox for the first record returned.

The initial getOrg query returns a list of all orgs in the org table. the getOrg2 query is supposed to return the org_id for all orgs that the user is associated with. The queries are returning the correct result sets - just the checkboxes are screwy. Ideas? thanks!
    This topic is closed to new replies. Start a new post to keep the conversation going.
    SojoviCorrect answer
    Inspiring
    Aug 21, 2006 8:48 PM UTC
    One of the possibilities to solve it :

    Regards

    3 replies

    SojoviCorrect answer
    Inspiring
    Aug 21, 2006 8:48 PM UTC
    One of the possibilities to solve it :

    Regards
    Translate
    cfjessAuthor
    Known Participant
    Aug 21, 2006 8:28 PM UTC
    If you mean just moving the getOrg2 query inside the <cfoutput query="getOrg"> tag, that didn't work either.

    I tried changing the <cfoutput query="getOrg"> to <cfloop query="getOrg"> and put the getOrg2 query inside the cfloop, but that didn't work either. It's definately looping over getOrg2, b/c in the debugging info, I see the mutltiple instances of the getOrg2 query.

    I also tried this - but it only returned the two records from getOrg2 - not all the org records possible.

    <cfquery name="getOrg2" datasource="#application.dsn#">
    SELECT org_id, user_id FROM user_org WHERE user_id = #form.user_id#
    </cfquery>

    <cfloop query="getOrg2">
    <cfoutput>
    <input type="checkbox" name="org_id" value="#org_id#" <CFIF getOrg.org_id IS getOrg2.org_ID>CHECKED</CFIF>>#getOrg.org_cd#<br /></cfoutput>
    </cfloop>
    Translate
    Aug 21, 2006 8:09 PM UTC
    You're not looping over getOrg2, so it continues to give you the first value.
    Translate