Submitting to CFDIV Problem

Posted on 2011-03-23
Last Modified: 2012-08-13
Hi there.  I tried to submit to a CFDIV from a CFFORM on the same page but it appears that the check box's value is always the same regardless if it is checked or not.

Can somebody help?

Thanks in advance.

   <form method="Post" name="FormSearch" id="FormSearch" target="SearchResult">
      <input name="Search" type="text" />
      <input name="Search2" type="checkbox" value="checkedBoxValue" />
      <input name="Search3" type="text" />
      <input name="Submit" type="button" value="SEARCH" onClick="ColdFusion.Ajax.submitForm("This");" />
   <cfdiv id="SearchResult" bind="url:SampleDivSubmitResults.cfm?Search={Search}&Search2={Search2}&Search3={Search3}" />

Open in new window

This is what it looks like when it is checked (notice the value in search 2) This is what it looks like when it is unchecked (notice the value in search 2 is still there) This is what it looks like when it is unchecked (notice the value in search 2 is still there) This is what it looks like when it is checked (notice the value in search 2)
Question by:SFTProd
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 82

Expert Comment

ID: 35202931
Try to replace with :

<input name="Search2" type="checkbox" value="checkedBoxValue" onclick="this.value = (this.checked?'checkedBoxValue':'')" />

Open in new window

LVL 52

Expert Comment

ID: 35203038
the check box's value is always the same regardless if it is checked or not

That's because a checkbox's value never changes, it's state is what changes (checked or unchecked)

I'm not real familiar with the ajax stuff.  But I'm not sure there's a slick way to conditionally pass the "value" the way you want.  leakim971's suggestion worked for me, with the addition of this code

<input name="Search2" type="checkbox" value="checkedBoxValue" onclick="this.value = (this.checked?'checkedBoxValue':'')" />
<cfdiv id="SearchResult" bind="url:SampleDivSubmitResults.cfm?Search={Search}&Search2={Search2.value@click}&Search3={Search3}" />
LVL 39

Expert Comment

ID: 35207412

I think you should be using ColdFusion.navigate

It has the built in ability to post of form asynchronously and it allows you to provide a target (which would be the CFDIV).

I think this is a very simple way of doing what you are attempting
Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

LVL 52

Expert Comment

ID: 35208551
Be sure to check the user comments at the bottom of that page.  Last time I used it, the parameter order was wrong ... which caused me some confusion at first ;-)

> I think you should be using ColdFusion.navigate

What's the goal?  Do you want to update the cfdiv only when the form is submitted OR whenever any of the form fields changes? If it's the former, then gdemaria's suggestion is the way to go. If it's the latter, then use a bind.

Author Comment

ID: 35209400
I am looking to bind multiple fields to a CFDIV. So, if the form changes in value, I would like it to submit to the CFDIV on the same page.

It is easy to bind it to a single field but I am not sure how to bind it to the whole form itself.

Thanks in advance.
LVL 11

Accepted Solution

Brijesh Chauhan earned 500 total points
ID: 35369646
The first 2 post does work and you get all the form fields in the div, including the checkbox attribute.


   <cfform name="FormSearch" id="FormSearch">
      <cfinput name="Search" type="text" />
      <input name="Search2" type="checkbox" onclick="this.value = (this.checked?'checkedBoxValue':'')"/>
      <cfinput name="Search3" type="text" />
<cfdiv bind="search={Search@keyup},checkbox={Search2.value@click},Search3={Search3@keyup}" id="SearchResult"/>

Open in new window


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API ( has made its way into the popular lexicon of the English language.  A few years ago, …
OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question