4 Replies Latest reply on Feb 8, 2010 2:26 PM by emmim44

    check boxes toggle using form.submit()

    emmim44 Level 1

      Hi guyz, when a checkkbox is clicked other than "form.locAll", it should store the value of those form.location in a session so that I can use them during the session. By default form.locAll is checked... The problem is: if any other cb is checked, when I clicked the "All" cb it doesnt reset other form.location cboxes. Basically it should toggle between form.locAll and form.location.

      Thank you alll.

      ----------Code----

      <cfparam name="form.location" default="">
      <cfparam name="session.location" default="All">
      <cfparam name="url.reset" default="0">
      <cfparam name="url.location" default="All">


      <cfif isdefined('form.LocAll') and trim(form.LocAll) eq "All" and not isdefined('form.location')>
      <cfset form.location = "">
      <cfelseif isdefined('form.location') and form.location neq "">
         <cfset session.location = form.location>
      </cfif>

       

       

      <form>

                <cfoutput query="GetDivisions">
                <input type="checkbox" name="<cfif trim(division) eq "All">LocAll<cfelse>location</cfif>"  id="#trim(DIVISION)#" value="#trim(DIVISION)#"          onClick="document.LOAAcc.submit();"
                <cfif form.location eq "" and trim(division) eq "All">
                 checked="checked"
                <cfelse>
                 <cfloop list="#form.location#" index="a">
                  <cfif trim(a) eq trim(DIVISION)>checked="checked"</cfif>
                 </cfloop>
                </cfif>
                 >
                <label for="#DIVISION#">#DIVISION#</label>
                </cfoutput>

      </form>

        • 1. Re: check boxes toggle using form.submit()
          Dan Bracuk Level 5

          What you are trying to accomplish is not clear.  No matter what it is, the following things might be preventing it.

           

          This

          <cfparam name="form.location" default="">
          combined with this
          <cfif isdefined('form.LocAll') and trim(form.LocAll) eq "All" and not isdefined('form.location')>

           

          is a problem because form.location will always be defined.

           


          This:

          <cfoutput query="GetDivisions">
                    <input type="checkbox" name="<cfif trim(division) eq "All">LocAll<cfelse>location</cfif>"  id="#trim(DIVISION)#" value="#trim(DIVISION)#"          onClick="document.LOAAcc.submit();"
                    <cfif form.location eq "" and trim(division) eq "All">
                     checked="checked"
                    <cfelse>
                     <cfloop list="#form.location#" index="a">
                      <cfif trim(a) eq trim(DIVISION)>checked="checked"</cfif>
                     </cfloop>
                    </cfif>
                     >

          has a lot of potential to go bad.

          First, if GetDivisions has more than one record, the user can only select one checkbox because of the onClick event.  Of course it's not clear what would be submitted because your form does not have a name.

          Next, looping through a list to set a checked attribute is logically the same as using ListFind.  If nothing else, it looks strange.

          • 2. Re: check boxes toggle using form.submit()
            emmim44 Level 1

            it is resolved. it was a small logic operation. thank you Dan.

            • 3. Re: check boxes toggle using form.submit()
              BKBK Adobe Community Professional & MVP
              it is resolved. it was a small logic operation.

              Good. Please kindly show the solution or, at the very least, explain briefly how you resolved the problem. Then, mark this thread as solved.

               

              It will help those who come here looking for answers to similar problems. You know it makes sense. Thank you.

              • 4. Re: check boxes toggle using form.submit()
                emmim44 Level 1

                The changes are:

                <cfif isdefined('form.location') and form.location neq "">
                <cfparam name="form.LocAll" default="">
                <cfset session.location = form.location>
                </cfif>
                <cfif isdefined('session.location') and session.location neq "All" and isdefined('url.indicator')>
                  <cfparam name="form.LocAll" default="">
                </cfif>


                <cfif isdefined('url.reset') and url.reset eq 1 and form.location eq "">
                <cfset session.location ="All">
                <cfparam name="url.reset" default="0">
                </cfif>

                 

                          <cfoutput query="GetDivisions">
                          <input type="checkbox" name="<cfif trim(division) eq "All">LocAll<cfelse>location</cfif>"
                           id="#trim(DIVISION)#" value="#trim(DIVISION)#"
                           <cfif trim(division) neq "All">
                           onClick="document.LOAAcc.submit();"
                           <cfelse>
                           onClick="javascript:window.location='index.cfm?Reset=1';"
                           </cfif>
                          <cfif form.location eq "" and trim(division) eq "All">
                           <cfif session.location eq "All" and trim(division) eq "All">
                            checked="checked"
                           </cfif>
                          <cfelse>
                           <cfif form.location neq "">
                            <cfloop
                            list="#form.location#"
                             index="a">
                             <cfif trim(a) eq trim(DIVISION)>checked="checked"</cfif>
                             </cfloop>
                            <cfelseif session.location neq "">
                             <cfloop
                             list="#session.location#"
                              index="a">
                              <cfif trim(a) eq trim(DIVISION)>checked="checked"</cfif>
                              </cfloop>
                            </cfif>
                          </cfif>
                           >
                          <label for="#DIVISION#">#DIVISION#</label>
                          </cfoutput>