Solved

Submitting to CFDIV Problem

Posted on 2011-03-23
6
757 Views
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.
<head>
<title></title>
</head>

<body>
   <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");" />
   </form>
   <cfdiv id="SearchResult" bind="url:SampleDivSubmitResults.cfm?Search={Search}&Search2={Search2}&Search3={Search3}" />
</body>
</html>

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)
0
Comment
Question by:SFTProd
6 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 35202931
Try to replace with :


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

Open in new window

0
 
LVL 52

Expert Comment

by:_agx_
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}" />
0
 
LVL 39

Expert Comment

by:gdemaria
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

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=JavaScriptFcns_24.html
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 52

Expert Comment

by:_agx_
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.
0
 

Author Comment

by:SFTProd
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.
0
 
LVL 11

Accepted Solution

by:
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.

<head>
<title></title>

<body>
   <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" />
   </cfform>
   
<cfdiv bind="search={Search@keyup},checkbox={Search2.value@click},Search3={Search3@keyup}" id="SearchResult"/>
</body>
</html>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now