Solved

Submitting to CFDIV Problem

Posted on 2011-03-23
6
758 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
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 …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
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, fr…

816 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

8 Experts available now in Live!

Get 1:1 Help Now