Skip to main content
Inspiring
February 5, 2010
Question

check boxes toggle using form.submit()

  • February 5, 2010
  • 1 reply
  • 927 views

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>

This topic has been closed for replies.

1 reply

Inspiring
February 5, 2010

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.

emmim44Author
Inspiring
February 5, 2010

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

BKBK
Community Expert
Community Expert
February 6, 2010
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.